Krystalan commited on
Commit
d151fa4
β€’
1 Parent(s): cafabdc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +105 -1
README.md CHANGED
@@ -10,4 +10,108 @@ tags:
10
  - O1-like model
11
  - Chat
12
  pipeline_tag: text-generation
13
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  - O1-like model
11
  - Chat
12
  pipeline_tag: text-generation
13
+ ---
14
+
15
+ # DRT-o1
16
+
17
+ <p align="center">
18
+ πŸ€— <a href="https://huggingface.co/Krystalan/DRT-o1-7B">DRT-o1-7B</a>&nbsp&nbsp | &nbsp&nbspπŸ€— <a href="https://huggingface.co/Krystalan/DRT-o1-14B">DRT-o1-14B</a>&nbsp&nbsp | &nbsp&nbsp πŸ“‘ <a href="https://arxiv.org/abs/2412.17498">Paper</a>
19
+
20
+ </p>
21
+
22
+ This repository contains the resources for our paper ["DRT-o1: Optimized Deep Reasoning Translation via Long Chain-of-Thought"](https://arxiv.org/abs/2412.17498)
23
+
24
+
25
+ ### Updates:
26
+ - *2024.12.24*: We released [our paper](https://arxiv.org/abs/2412.17498). Check it out!
27
+ - *2024.12.23*: We released our model checkpoints. πŸ€— <a href="https://huggingface.co/Krystalan/DRT-o1-7B">DRT-o1-7B</a> and πŸ€— <a href="https://huggingface.co/Krystalan/DRT-o1-14B">DRT-o1-14B</a>.
28
+
29
+
30
+ ## Introduction
31
+
32
+ In this work, we introduce DRT-o1, an attempt to bring the success of long thought reasoning to neural machine translation (MT). To this end,
33
+ - 🌟 We mine English sentences with similes or metaphors from existing literature books, which are suitable for translation via long thought.
34
+ - 🌟 We propose a designed multi-agent framework with three agents (i.e., a translator, an advisor and an evaluator) to synthesize the MT samples with long thought. There are 22,264 synthesized samples in total.
35
+ - 🌟 We train DRT-o1-7B and DRT-o1-14B using Qwen2.5-7B-Instruct and Qwen2.5-14B-Instruct as backbones.
36
+
37
+
38
+
39
+ ## Quickstart
40
+
41
+ ### ⛷️ Huggingface Transformers
42
+
43
+ ```python
44
+ from transformers import AutoModelForCausalLM, AutoTokenizer
45
+
46
+ model_name = "Krystalan/DRT-o1-7B"
47
+
48
+ model = AutoModelForCausalLM.from_pretrained(
49
+ model_name,
50
+ torch_dtype="auto",
51
+ device_map="auto"
52
+ )
53
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
54
+
55
+ prompt = "Please translate the following text from English to Chinese:\nThe mother, with her feet propped up on a stool, seemed to be trying to get to the bottom of that answer, whose feminine profundity had struck her all of a heap."
56
+ messages = [
57
+ {"role": "system", "content": "You are a philosopher skilled in deep thinking, accustomed to exploring complex problems with profound insight."},
58
+ {"role": "user", "content": prompt}
59
+ ]
60
+ text = tokenizer.apply_chat_template(
61
+ messages,
62
+ tokenize=False,
63
+ add_generation_prompt=True
64
+ )
65
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
66
+
67
+ generated_ids = model.generate(
68
+ **model_inputs,
69
+ max_new_tokens=2048
70
+ )
71
+ generated_ids = [
72
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
73
+ ]
74
+
75
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
76
+ print(response)
77
+ ```
78
+
79
+ ### ⛷️ vllm
80
+
81
+ Deploying LLMs:
82
+ ```bash
83
+ python3 -m vllm.entrypoints.openai.api_server --model [model_ckpt] --served-model-name [model_name]
84
+ ```
85
+
86
+ Calling LLMs:
87
+ ```python
88
+ from openai import OpenAI
89
+ # Set OpenAI's API key and API base to use vLLM's API server.
90
+ openai_api_key = "EMPTY"
91
+ openai_api_base = "http://localhost:8000/v1"
92
+
93
+ client = OpenAI(
94
+ api_key=openai_api_key,
95
+ base_url=openai_api_base,
96
+ )
97
+
98
+ chat_response = client.chat.completions.create(
99
+ model=[model_name],
100
+ messages=[
101
+ {"role": "system", "content": "You are a philosopher skilled in deep thinking, accustomed to exploring complex problems with profound insight."},
102
+ {"role": "user", "content": "Please translate the following text from English to Chinese:\nThe mother, with her feet propped up on a stool, seemed to be trying to get to the bottom of that answer, whose feminine profundity had struck her all of a heap."},
103
+ ],
104
+ temperature=0.7,
105
+ top_p=0.8,
106
+ max_tokens=2048,
107
+ extra_body={
108
+ "repetition_penalty": 1.05,
109
+ },
110
+ )
111
+ print("Chat response:", chat_response)
112
+ ```
113
+
114
+
115
+ ## License
116
+ This work is licensed under cc-by-nc-sa-4.0
117
+