Commit
·
8e5e349
1
Parent(s):
a6f9565
Auto-generated model card.
Browse files- README.md +119 -0
- model_card.py +90 -0
README.md
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
language: en
|
4 |
+
tags:
|
5 |
+
- bert-finetuned-mrpc
|
6 |
+
- sequence-classification
|
7 |
+
license: unknown
|
8 |
+
---
|
9 |
+
|
10 |
+
# Bert-finetuned-mrpc Fine-tuned for Sequence classification
|
11 |
+
|
12 |
+
This model is a fine-tuned version of [bert-finetuned-mrpc](https://huggingface.co/bert-finetuned-mrpc) for sequence classification tasks.
|
13 |
+
|
14 |
+
## Model description
|
15 |
+
|
16 |
+
- Model architecture: BertForSequenceClassification
|
17 |
+
- Task: sequence-classification
|
18 |
+
- Training dataset: bert-finetuned-mrpc
|
19 |
+
- Number of parameters: 109,483,778
|
20 |
+
- Sequence length: 512
|
21 |
+
- Vocab size: 30522
|
22 |
+
- Hidden size: 768
|
23 |
+
- Number of attention heads: 12
|
24 |
+
- Number of hidden layers: 12
|
25 |
+
|
26 |
+
## Intended uses & limitations
|
27 |
+
|
28 |
+
This model is intended for sequence classification tasks. It has been fine-tuned on a specific dataset, so its performance may vary on different datasets or domains.
|
29 |
+
|
30 |
+
## Training procedure
|
31 |
+
|
32 |
+
The model was fine-tuned using the following hyperparameters:
|
33 |
+
{
|
34 |
+
"return_dict": true,
|
35 |
+
"output_hidden_states": false,
|
36 |
+
"output_attentions": false,
|
37 |
+
"torchscript": false,
|
38 |
+
"torch_dtype": "float32",
|
39 |
+
"use_bfloat16": false,
|
40 |
+
"tf_legacy_loss": false,
|
41 |
+
"pruned_heads": {},
|
42 |
+
"tie_word_embeddings": true,
|
43 |
+
"chunk_size_feed_forward": 0,
|
44 |
+
"is_encoder_decoder": false,
|
45 |
+
"is_decoder": false,
|
46 |
+
"cross_attention_hidden_size": null,
|
47 |
+
"add_cross_attention": false,
|
48 |
+
"tie_encoder_decoder": false,
|
49 |
+
"max_length": 20,
|
50 |
+
"min_length": 0,
|
51 |
+
"do_sample": false,
|
52 |
+
"early_stopping": false,
|
53 |
+
"num_beams": 1,
|
54 |
+
"num_beam_groups": 1,
|
55 |
+
"diversity_penalty": 0.0,
|
56 |
+
"temperature": 1.0,
|
57 |
+
"top_k": 50,
|
58 |
+
"top_p": 1.0,
|
59 |
+
"typical_p": 1.0,
|
60 |
+
"repetition_penalty": 1.0,
|
61 |
+
"length_penalty": 1.0,
|
62 |
+
"no_repeat_ngram_size": 0,
|
63 |
+
"encoder_no_repeat_ngram_size": 0,
|
64 |
+
"bad_words_ids": null,
|
65 |
+
"num_return_sequences": 1,
|
66 |
+
"output_scores": false,
|
67 |
+
"return_dict_in_generate": false,
|
68 |
+
"forced_bos_token_id": null,
|
69 |
+
"forced_eos_token_id": null,
|
70 |
+
"remove_invalid_values": false,
|
71 |
+
"exponential_decay_length_penalty": null,
|
72 |
+
"suppress_tokens": null,
|
73 |
+
"begin_suppress_tokens": null,
|
74 |
+
"architectures": [
|
75 |
+
"BertForSequenceClassification"
|
76 |
+
],
|
77 |
+
"finetuning_task": null,
|
78 |
+
"id2label": {
|
79 |
+
"0": "LABEL_0",
|
80 |
+
"1": "LABEL_1"
|
81 |
+
},
|
82 |
+
"label2id": {
|
83 |
+
"LABEL_0": 0,
|
84 |
+
"LABEL_1": 1
|
85 |
+
},
|
86 |
+
"tokenizer_class": null,
|
87 |
+
"prefix": null,
|
88 |
+
"bos_token_id": null,
|
89 |
+
"pad_token_id": 0,
|
90 |
+
"eos_token_id": null,
|
91 |
+
"sep_token_id": null,
|
92 |
+
"decoder_start_token_id": null,
|
93 |
+
"task_specific_params": null,
|
94 |
+
"problem_type": "single_label_classification",
|
95 |
+
"_name_or_path": "bert-finetuned-mrpc",
|
96 |
+
"transformers_version": "4.38.1",
|
97 |
+
"gradient_checkpointing": false,
|
98 |
+
"model_type": "bert",
|
99 |
+
"vocab_size": 30522,
|
100 |
+
"hidden_size": 768,
|
101 |
+
"num_hidden_layers": 12,
|
102 |
+
"num_attention_heads": 12,
|
103 |
+
"hidden_act": "gelu",
|
104 |
+
"intermediate_size": 3072,
|
105 |
+
"hidden_dropout_prob": 0.1,
|
106 |
+
"attention_probs_dropout_prob": 0.1,
|
107 |
+
"max_position_embeddings": 512,
|
108 |
+
"type_vocab_size": 2,
|
109 |
+
"initializer_range": 0.02,
|
110 |
+
"layer_norm_eps": 1e-12,
|
111 |
+
"position_embedding_type": "absolute",
|
112 |
+
"use_cache": true,
|
113 |
+
"classifier_dropout": null
|
114 |
+
}
|
115 |
+
|
116 |
+
## Evaluation results
|
117 |
+
|
118 |
+
[Evaluation results to be added]
|
119 |
+
|
model_card.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import Repository, HfApi
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer, AutoConfig
|
3 |
+
import json
|
4 |
+
|
5 |
+
# Initialize the Hugging Face API client
|
6 |
+
api = HfApi()
|
7 |
+
|
8 |
+
# Use the existing local repository
|
9 |
+
repo = Repository("local-folder")
|
10 |
+
repo.git_pull()
|
11 |
+
|
12 |
+
# Load the model, tokenizer, and config from the existing checkpoint
|
13 |
+
checkpoint_directory = "bert-finetuned-mrpc"
|
14 |
+
model = AutoModelForSequenceClassification.from_pretrained(checkpoint_directory)
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint_directory)
|
16 |
+
config = AutoConfig.from_pretrained(checkpoint_directory)
|
17 |
+
|
18 |
+
# Get the repository name
|
19 |
+
repo_name = "amannagrawall002/bert-finetued-mrpc" # Replace this with your actual repository name
|
20 |
+
|
21 |
+
# Generate model card content
|
22 |
+
model_name = config.name_or_path.split('/')[-1]
|
23 |
+
task = list(config.task_specific_params.keys())[0] if hasattr(config, 'task_specific_params') and config.task_specific_params else "sequence-classification"
|
24 |
+
architecture = config.architectures[0] if hasattr(config, 'architectures') and config.architectures else "Unknown"
|
25 |
+
|
26 |
+
model_card_content = f"""
|
27 |
+
---
|
28 |
+
language: en
|
29 |
+
tags:
|
30 |
+
- {model_name}
|
31 |
+
- {task}
|
32 |
+
license: {config.license if hasattr(config, 'license') else 'unknown'}
|
33 |
+
---
|
34 |
+
|
35 |
+
# {model_name.capitalize()} Fine-tuned for {task.replace('-', ' ').capitalize()}
|
36 |
+
|
37 |
+
This model is a fine-tuned version of [{model_name}](https://huggingface.co/{config.name_or_path}) for {task.replace('-', ' ')} tasks.
|
38 |
+
|
39 |
+
## Model description
|
40 |
+
|
41 |
+
- Model architecture: {architecture}
|
42 |
+
- Task: {task}
|
43 |
+
- Training dataset: {config._name_or_path if hasattr(config, '_name_or_path') else 'Unknown'}
|
44 |
+
- Number of parameters: {model.num_parameters():,}
|
45 |
+
- Sequence length: {config.max_position_embeddings}
|
46 |
+
- Vocab size: {config.vocab_size}
|
47 |
+
- Hidden size: {config.hidden_size}
|
48 |
+
- Number of attention heads: {config.num_attention_heads}
|
49 |
+
- Number of hidden layers: {config.num_hidden_layers}
|
50 |
+
|
51 |
+
## Intended uses & limitations
|
52 |
+
|
53 |
+
This model is intended for {task.replace('-', ' ')} tasks. It has been fine-tuned on a specific dataset, so its performance may vary on different datasets or domains.
|
54 |
+
|
55 |
+
## Training procedure
|
56 |
+
|
57 |
+
The model was fine-tuned using the following hyperparameters:
|
58 |
+
{json.dumps(config.to_dict(), indent=2)}
|
59 |
+
|
60 |
+
## Evaluation results
|
61 |
+
|
62 |
+
[Evaluation results to be added]
|
63 |
+
|
64 |
+
"""
|
65 |
+
|
66 |
+
with open(f"{repo.local_dir}/README.md", "w") as f:
|
67 |
+
f.write(model_card_content)
|
68 |
+
|
69 |
+
# Add inference API code
|
70 |
+
# pipeline_code = f"""
|
71 |
+
# from transformers import pipeline
|
72 |
+
|
73 |
+
# def inference(text):
|
74 |
+
# classifier = pipeline("{task}", model="{repo_name}")
|
75 |
+
# result = classifier(text)
|
76 |
+
# return result
|
77 |
+
# """
|
78 |
+
|
79 |
+
# with open(f"{repo.local_dir}/api.py", "w") as f:
|
80 |
+
# f.write(pipeline_code)
|
81 |
+
|
82 |
+
# Commit and push changes
|
83 |
+
repo.git_add()
|
84 |
+
repo.git_commit("Added auto-generated model card")
|
85 |
+
repo.git_push()
|
86 |
+
|
87 |
+
# Enable the Inference API
|
88 |
+
# api.add_space_secret(repo_name, "INFERENCE_ENDPOINT", f"https://api-inference.huggingface.co/models/{repo_name}")
|
89 |
+
|
90 |
+
print("Auto-generated model card.")
|