sachithgunasekara commited on
Commit
fd9ece1
·
verified ·
1 Parent(s): 670b1a6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -5
README.md CHANGED
@@ -8,14 +8,17 @@ pipeline_tag: text-generation
8
  library_name: transformers
9
  tags:
10
  - chat
 
 
11
  ---
12
 
13
  ## Quickstart
14
 
15
- Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
16
 
17
  ```python
18
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
19
 
20
  model_name = "SurgeGlobal/s1-1.1-Qwen-2.5-1.5B-Instruct"
21
 
@@ -26,7 +29,9 @@ model = AutoModelForCausalLM.from_pretrained(
26
  )
27
  tokenizer = AutoTokenizer.from_pretrained(model_name)
28
 
29
- prompt = "Give me a short introduction to large language model."
 
 
30
  messages = [
31
  {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
32
  {"role": "user", "content": prompt}
@@ -40,13 +45,12 @@ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
40
 
41
  generated_ids = model.generate(
42
  **model_inputs,
43
- max_new_tokens=512
 
44
  )
45
  generated_ids = [
46
  output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
47
  ]
48
 
49
  response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
50
-
51
- print(response)
52
  ```
 
8
  library_name: transformers
9
  tags:
10
  - chat
11
+ datasets:
12
+ - simplescaling/s1K-1.1_tokenized
13
  ---
14
 
15
  ## Quickstart
16
 
17
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
18
 
19
  ```python
20
  from transformers import AutoModelForCausalLM, AutoTokenizer
21
+ from transformers import TextStreamer
22
 
23
  model_name = "SurgeGlobal/s1-1.1-Qwen-2.5-1.5B-Instruct"
24
 
 
29
  )
30
  tokenizer = AutoTokenizer.from_pretrained(model_name)
31
 
32
+ streamer = TextStreamer(tokenizer, skip_prompt=True)
33
+
34
+ prompt = "How would a typical person answer each of the following questions about causation? A machine is set up in such a way that it will short circuit if both the black wire and the red wire touch the battery at the same time. The machine will not short circuit if just one of these wires touches the battery. The black wire is designated as the one that is supposed to touch the battery, while the red wire is supposed to remain in some other part of the machine. One day, the black wire and the red wire both end up touching the battery at the same time. There is a short circuit. Did the black wire cause the short circuit? Options: - Yes - No"
35
  messages = [
36
  {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
37
  {"role": "user", "content": prompt}
 
45
 
46
  generated_ids = model.generate(
47
  **model_inputs,
48
+ max_new_tokens=8000,
49
+ streamer=streamer
50
  )
51
  generated_ids = [
52
  output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
53
  ]
54
 
55
  response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
 
 
56
  ```