sudy-super commited on
Commit
c723e92
1 Parent(s): 1aa1ec3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -7
README.md CHANGED
@@ -23,19 +23,21 @@ Yamase-12B-v0.1は、[Mistral-Nemo-Instruct](https://huggingface.co/mistralai/Mi
23
  ```python
24
  import torch
25
  from transformers import AutoModelForCausalLM, AutoTokenizer
26
- B_INST, E_INST = "[INST]", "[/INST]"
27
  text = "旅行に行くと高層ビルがたくさん建っていました。これからどのようなことが推測できますか?"
28
  model_name = "sudy-super/Yamase-12B"
29
  tokenizer = AutoTokenizer.from_pretrained(model_name)
30
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
31
  if torch.cuda.is_available():
32
  model = model.to("cuda")
33
  model.eval()
34
- prompt = "{bos_token}{b_inst}{prompt}{e_inst}".format(
35
- bos_token=tokenizer.bos_token,
36
- b_inst=B_INST,
37
- prompt=text,
38
- e_inst=E_INST,
 
 
39
  )
40
  with torch.no_grad():
41
  token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
 
23
  ```python
24
  import torch
25
  from transformers import AutoModelForCausalLM, AutoTokenizer
26
+
27
  text = "旅行に行くと高層ビルがたくさん建っていました。これからどのようなことが推測できますか?"
28
  model_name = "sudy-super/Yamase-12B"
29
  tokenizer = AutoTokenizer.from_pretrained(model_name)
30
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16,)
31
  if torch.cuda.is_available():
32
  model = model.to("cuda")
33
  model.eval()
34
+ messages = [
35
+ {"role": "user", "content": text},
36
+ ]
37
+ prompt = tokenizer.apply_chat_template(
38
+ messages,
39
+ tokenize=False,
40
+ add_generation_prompt=True,
41
  )
42
  with torch.no_grad():
43
  token_ids = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")