Di Zhang commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -7,7 +7,7 @@ tags:
|
|
| 7 |
- full
|
| 8 |
- generated_from_trainer
|
| 9 |
model-index:
|
| 10 |
-
- name:
|
| 11 |
results: []
|
| 12 |
---
|
| 13 |
|
|
@@ -16,45 +16,45 @@ should probably proofread and complete it, then remove this comment. -->
|
|
| 16 |
|
| 17 |
# longcot_sft_llama3.1_ZD_11_29_1
|
| 18 |
|
| 19 |
-
This model is a fine-tuned version of [/
|
| 20 |
|
| 21 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
More information needed
|
| 24 |
|
| 25 |
-
## Intended uses & limitations
|
| 26 |
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
-
## Training and evaluation data
|
| 30 |
|
| 31 |
-
More information needed
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
The following hyperparameters were used during training:
|
| 38 |
-
- learning_rate: 5e-06
|
| 39 |
-
- train_batch_size: 1
|
| 40 |
-
- eval_batch_size: 8
|
| 41 |
-
- seed: 42
|
| 42 |
-
- distributed_type: multi-GPU
|
| 43 |
-
- num_devices: 24
|
| 44 |
-
- gradient_accumulation_steps: 16
|
| 45 |
-
- total_train_batch_size: 384
|
| 46 |
-
- total_eval_batch_size: 192
|
| 47 |
-
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 48 |
-
- lr_scheduler_type: cosine
|
| 49 |
-
- num_epochs: 2.0
|
| 50 |
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
- Transformers 4.46.2
|
| 58 |
-
- Pytorch 2.3.1
|
| 59 |
-
- Datasets 3.1.0
|
| 60 |
-
- Tokenizers 0.20.1
|
|
|
|
| 7 |
- full
|
| 8 |
- generated_from_trainer
|
| 9 |
model-index:
|
| 10 |
+
- name: SimpleBerry/LLaMA-O1-Supervised-1129
|
| 11 |
results: []
|
| 12 |
---
|
| 13 |
|
|
|
|
| 16 |
|
| 17 |
# longcot_sft_llama3.1_ZD_11_29_1
|
| 18 |
|
| 19 |
+
This model is a fine-tuned version of [SimpleBerry/LLaMA-O1-Base-1127](https://huggingface.co/SimpleBerry/LLaMA-O1-Base-1127) on the [SimpleBerry/OpenLongCoT-SFT](SimpleBerry/OpenLongCoT-SFT) dataset.
|
| 20 |
|
| 21 |
+
# Inference
|
| 22 |
+
```Python
|
| 23 |
+
import json
|
| 24 |
+
import datasets
|
| 25 |
+
import torch
|
| 26 |
+
import random
|
| 27 |
+
import numpy as np
|
| 28 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 29 |
|
|
|
|
| 30 |
|
|
|
|
| 31 |
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained("/mnt/hwfile/ai4chem/CKPT/longcot_sft_llama3.1_ZD_11_29_1/")
|
| 33 |
+
model = AutoModelForCausalLM.from_pretrained("/mnt/hwfile/ai4chem/CKPT/longcot_sft_llama3.1_ZD_11_29_1/",device_map='auto')
|
| 34 |
|
|
|
|
| 35 |
|
|
|
|
| 36 |
|
| 37 |
+
template = "<start_of_father_id>-1<end_of_father_id><start_of_local_id>0<end_of_local_id><start_of_thought><problem>{content}<end_of_thought><start_of_rating><positive_rating><end_of_rating>\n<start_of_father_id>0<end_of_father_id><start_of_local_id>1<end_of_local_id><start_of_thought><expansion>"
|
| 38 |
|
| 39 |
+
def llama_o1_template(data):
|
| 40 |
+
query = data['query']
|
| 41 |
+
text = template.format(content=query)
|
| 42 |
+
return text
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
def batch_predict(input_texts):
|
| 46 |
+
input_texts = [input_text.replace('<|end_of_text|>','') for input_text in input_texts]
|
| 47 |
+
inputs = tokenizer(input_texts, return_tensors="pt").to(model.device)
|
| 48 |
+
responses = model.generate(**inputs, max_new_tokens=1024)
|
| 49 |
+
response_texts = tokenizer.batch_decode(responses, skip_special_tokens=False)
|
| 50 |
+
# assitant_responses = [item[len(input_texts[i]):] for i,item in enumerate(response_texts)]
|
| 51 |
+
assitant_responses = [item for i,item in enumerate(response_texts)]
|
| 52 |
+
return assitant_responses
|
| 53 |
|
| 54 |
|
| 55 |
+
i = input()
|
| 56 |
+
input_texts = [llama_o1_template(i)]
|
| 57 |
+
assitant_responses = batch_predict(input_texts)
|
| 58 |
+
print(assitant_responses)
|
| 59 |
|
| 60 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|