cahya commited on
Commit
e911ee1
1 Parent(s): 3ea080c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -8
README.md CHANGED
@@ -24,18 +24,18 @@ anh-bloomz-7b1-mt-cross-lingual model can be loaded and used via the following c
24
  ```python
25
  import re
26
  from transformers import AutoModelForCausalLM, AutoTokenizer
27
- model = AutoModelForCausalLM.from_pretrained(
28
- "laion/anh-bloomz-7b1-mt-cross-lingual",
29
- )
30
- tokenizer = AutoTokenizer.from_pretrained(
31
- "laion/anh-bloomz-7b1-mt-cross-lingual",
32
- )
33
  whitespace_tokens_map = {'\n': '<n>', ' ': '<w>'}
34
- text = "User: Apa yang terjadi pada pertempuran Cannae? Jawab dalam bahasa China.\n"
35
  for k, v in whitespace_tokens_map.items():
36
  text = text.replace(k, v)
37
  inputs = tokenizer(text, return_tensors="pt")
38
- tokens = model.generate(**inputs)
 
39
  output = tokenizer.decode(tokens[0], skip_special_tokens=True)
40
  for v in whitespace_tokens_map.values():
41
  output = re.sub(rf"{v}\s+(\S+)", rf"{v}\1", output)
 
24
  ```python
25
  import re
26
  from transformers import AutoModelForCausalLM, AutoTokenizer
27
+
28
+ model_name = "laion/anh-bloomz-7b1-mt-cross-lingual"
29
+ model = AutoModelForCausalLM.from_pretrained(model_name)
30
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
31
+
 
32
  whitespace_tokens_map = {'\n': '<n>', ' ': '<w>'}
33
+ text = "User: Apakah kita akan bisa menyembuhkan penyakit kanker? Jawab dalam bahasa China.\n"
34
  for k, v in whitespace_tokens_map.items():
35
  text = text.replace(k, v)
36
  inputs = tokenizer(text, return_tensors="pt")
37
+ tokens = model.generate(**inputs, max_new_tokens=200, do_sample=True, top_k=40, top_p=0.9, temperature=0.2,
38
+ repetition_penalty=1.2,num_return_sequences=1)
39
  output = tokenizer.decode(tokens[0], skip_special_tokens=True)
40
  for v in whitespace_tokens_map.values():
41
  output = re.sub(rf"{v}\s+(\S+)", rf"{v}\1", output)