Triangle104 commited on
Commit
727fd6c
·
verified ·
1 Parent(s): c1b2943

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +86 -0
README.md CHANGED
@@ -17,6 +17,92 @@ pipeline_tag: text-generation
17
  This model was converted to GGUF format from [`Krystalan/DRT-o1-7B`](https://huggingface.co/Krystalan/DRT-o1-7B) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
18
  Refer to the [original model card](https://huggingface.co/Krystalan/DRT-o1-7B) for more details on the model.
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ## Use with llama.cpp
21
  Install llama.cpp through brew (works on Mac and Linux)
22
 
 
17
  This model was converted to GGUF format from [`Krystalan/DRT-o1-7B`](https://huggingface.co/Krystalan/DRT-o1-7B) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
18
  Refer to the [original model card](https://huggingface.co/Krystalan/DRT-o1-7B) for more details on the model.
19
 
20
+ ---
21
+ Model details:
22
+ -
23
+ This repository contains the resources for our paper "DRT-o1: Optimized Deep Reasoning Translation via Long Chain-of-Thought"
24
+
25
+ Updates:
26
+ 2024.12.24: We released our paper. Check it out!
27
+ 2024.12.23: We released our model checkpoints. 🤗 DRT-o1-7B and 🤗 DRT-o1-14B.
28
+ Introduction
29
+ 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,
30
+
31
+ 🌟 We mine English sentences with similes or metaphors from existing literature books, which are suitable for translation via long thought.
32
+ 🌟 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.
33
+ 🌟 We train DRT-o1-7B and DRT-o1-14B using Qwen2.5-7B-Instruct and Qwen2.5-14B-Instruct as backbones.
34
+ Quickstart
35
+ ⛷️ Huggingface Transformers
36
+ from transformers import AutoModelForCausalLM, AutoTokenizer
37
+
38
+ model_name = "Krystalan/DRT-o1-7B"
39
+
40
+ model = AutoModelForCausalLM.from_pretrained(
41
+ model_name,
42
+ torch_dtype="auto",
43
+ device_map="auto"
44
+ )
45
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
46
+
47
+ 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."
48
+ messages = [
49
+ {"role": "system", "content": "You are a philosopher skilled in deep thinking, accustomed to exploring complex problems with profound insight."},
50
+ {"role": "user", "content": prompt}
51
+ ]
52
+ text = tokenizer.apply_chat_template(
53
+ messages,
54
+ tokenize=False,
55
+ add_generation_prompt=True
56
+ )
57
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
58
+
59
+ generated_ids = model.generate(
60
+ **model_inputs,
61
+ max_new_tokens=2048
62
+ )
63
+ generated_ids = [
64
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
65
+ ]
66
+
67
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
68
+ print(response)
69
+
70
+ ⛷️ vllm
71
+ Deploying LLMs:
72
+
73
+ python3 -m vllm.entrypoints.openai.api_server --model [model_ckpt] --served-model-name [model_name]
74
+
75
+ Calling LLMs:
76
+
77
+ from openai import OpenAI
78
+ # Set OpenAI's API key and API base to use vLLM's API server.
79
+ openai_api_key = "EMPTY"
80
+ openai_api_base = "http://localhost:8000/v1"
81
+
82
+ client = OpenAI(
83
+ api_key=openai_api_key,
84
+ base_url=openai_api_base,
85
+ )
86
+
87
+ chat_response = client.chat.completions.create(
88
+ model=[model_name],
89
+ messages=[
90
+ {"role": "system", "content": "You are a philosopher skilled in deep thinking, accustomed to exploring complex problems with profound insight."},
91
+ {"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."},
92
+ ],
93
+ temperature=0.7,
94
+ top_p=0.8,
95
+ max_tokens=2048,
96
+ extra_body={
97
+ "repetition_penalty": 1.05,
98
+ },
99
+ )
100
+ print("Chat response:", chat_response)
101
+
102
+ License
103
+ This work is licensed under cc-by-nc-sa-4.0
104
+
105
+ ---
106
  ## Use with llama.cpp
107
  Install llama.cpp through brew (works on Mac and Linux)
108