nayohan commited on
Commit
42241bf
1 Parent(s): 6159d8f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +13 -2
README.md CHANGED
@@ -28,7 +28,11 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
28
 
29
  model_name = "nayohan/llama3-8b-translation-en-ko-1sent"
30
  tokenizer = AutoTokenizer.from_pretrained(model_name)
31
- model = AutoModelForCausalLM.from_pretrained(model_name,device_map="auto",torch_dtype=torch.float16)
 
 
 
 
32
  ```
33
 
34
  ### **Generating Text**
@@ -41,7 +45,14 @@ SYSTEM_PROMPT=f"Acts as a translator. Translate {source} sentences into {target}
41
  s = "The aerospace industry is a flower in the field of technology and science."
42
  conversation = [{'role': 'system', 'content': SYSTEM_PROMPT},
43
  {'role': 'user', 'content': s}]
44
- inputs = tokenizer.apply_chat_template(conversation,tokenize=True,add_generation_prompt=True,return_tensors='pt').to("cuda")
 
 
 
 
 
 
 
45
  outputs = model.generate(inputs, max_new_tokens=256)
46
  print(tokenizer.decode(outputs[0][len(inputs[0]):]))
47
  ```
 
28
 
29
  model_name = "nayohan/llama3-8b-translation-en-ko-1sent"
30
  tokenizer = AutoTokenizer.from_pretrained(model_name)
31
+ model = AutoModelForCausalLM.from_pretrained(
32
+ model_name,
33
+ device_map="auto",
34
+ torch_dtype=torch.float16
35
+ )
36
  ```
37
 
38
  ### **Generating Text**
 
45
  s = "The aerospace industry is a flower in the field of technology and science."
46
  conversation = [{'role': 'system', 'content': SYSTEM_PROMPT},
47
  {'role': 'user', 'content': s}]
48
+
49
+ inputs = tokenizer.apply_chat_template(
50
+ conversation,
51
+ tokenize=True,
52
+ add_generation_prompt=True,
53
+ return_tensors='pt'
54
+ ).to("cuda")
55
+
56
  outputs = model.generate(inputs, max_new_tokens=256)
57
  print(tokenizer.decode(outputs[0][len(inputs[0]):]))
58
  ```