DarianNLP commited on
Commit
6ae41e8
·
verified ·
1 Parent(s): 9a16424

uploaded weights

Browse files
weights_for_huggingface/README.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - regression
6
+ - similarity
7
+ - sql
8
+ - natural-language
9
+ - reward-model
10
+ license: mit
11
+ datasets:
12
+ - custom
13
+ metrics:
14
+ - mse
15
+ - mae
16
+ - rmse
17
+ model-index:
18
+ - name: BERT Reward Model for CoT Filtering
19
+ results:
20
+ - task:
21
+ type: regression
22
+ name: Similarity Score Prediction
23
+ dataset:
24
+ name: Custom CoT Dataset
25
+ type: custom
26
+ metrics:
27
+ - type: mse
28
+ value: 0.0238
29
+ - type: mae
30
+ value: 0.1229
31
+ - type: rmse
32
+ value: 0.1543
33
+ ---
34
+
35
+ # BERT Reward Model for CoT Filtering
36
+
37
+ A BERT-based regression model fine-tuned to predict similarity scores between SQL queries, reasoning chains (Chain-of-Thought), and natural language descriptions.
38
+
39
+ ## Model Description
40
+
41
+ This model is based on `bert-base-uncased` and has been fine-tuned for regression to predict similarity scores in the range [0, 1]. The model takes as input a concatenation of:
42
+ - SQL query
43
+ - Reasoning/Chain-of-Thought explanation
44
+ - Predicted natural language description
45
+
46
+ And outputs a similarity score indicating how well the predicted NL matches the ground truth.
47
+
48
+ ## Usage
49
+
50
+ ```python
51
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
52
+ import torch
53
+
54
+ # Load model and tokenizer
55
+ model_path = "path/to/weights_for_huggingface"
56
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
57
+ model = AutoModelForSequenceClassification.from_pretrained(
58
+ model_path,
59
+ num_labels=1,
60
+ problem_type="regression"
61
+ )
62
+ model.eval()
63
+
64
+ # Prepare input
65
+ sql = "SELECT movie_title FROM movies WHERE movie_release_year = 1945"
66
+ reasoning = "think: The SQL selects the movie title..."
67
+ predicted_nl = "What was the most popular movie released in 1945?"
68
+
69
+ input_text = f"SQL: {sql}\nReasoning: {reasoning}\nNL: {predicted_nl}"
70
+
71
+ # Tokenize and predict
72
+ inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512)
73
+ with torch.no_grad():
74
+ outputs = model(**inputs)
75
+ # Apply sigmoid to get probability
76
+ similarity_score = torch.sigmoid(outputs.logits).item()
77
+
78
+ print(f"Predicted similarity: {similarity_score:.3f}")
79
+ ```
80
+
81
+ ## Training Details
82
+
83
+ - **Base Model**: bert-base-uncased
84
+ - **Training Dataset**: Custom CoT dataset with corruptions (7,342 examples)
85
+ - **Train/Val/Test Split**: 75% / 12.5% / 12.5%
86
+ - **Training Loss**: MSE (Mean Squared Error)
87
+ - **Evaluation Metrics**:
88
+ - MSE: 0.0238
89
+ - MAE: 0.1229
90
+ - RMSE: 0.1543
91
+
92
+ ## Limitations
93
+
94
+ - Maximum input length: 512 tokens (BERT's limit)
95
+ - Trained on a specific domain (SQL to NL translation with CoT)
96
+ - Performance may vary on out-of-domain data
97
+
98
+ ## Citation
99
+
100
+ If you use this model, please cite:
101
+
102
+ ```bibtex
103
+ @misc{bert_cot_reward_model,
104
+ title={BERT Reward Model for Chain-of-Thought Filtering},
105
+ author={Your Name},
106
+ year={2024},
107
+ }
108
+ ```
109
+
weights_for_huggingface/config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "gradient_checkpointing": false,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "id2label": null,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "label2id": null,
15
+ "layer_norm_eps": 1e-12,
16
+ "max_position_embeddings": 512,
17
+ "model_type": "bert",
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "num_labels": 1,
21
+ "pad_token_id": 0,
22
+ "position_embedding_type": "absolute",
23
+ "problem_type": "regression",
24
+ "transformers_version": "4.57.1",
25
+ "type_vocab_size": 2,
26
+ "use_cache": true,
27
+ "vocab_size": 30522
28
+ }
weights_for_huggingface/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:844ef2517807f6ac2ea74068e7ee6d178ae89eaf02c08ef2aa531cf2f020d433
3
+ size 437955572
weights_for_huggingface/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
weights_for_huggingface/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
weights_for_huggingface/tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "BertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
weights_for_huggingface/vocab.txt ADDED
The diff for this file is too large to render. See raw diff