Konstantinos commited on
Commit
b01685a
·
verified ·
1 Parent(s): 254f21a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +22 -6
README.md CHANGED
@@ -9,7 +9,7 @@ tags:
9
  - text-generation
10
  - instruction-tuned
11
  - llama
12
- base_model: ComputationalLinguisticsPlatform/LexisLM-1B
13
  ---
14
 
15
  # LexisLM-1B-Instruct
@@ -34,20 +34,36 @@ The chat template prepends `<eos>`, formats each message as `<|role|>` followed
34
  ## Usage
35
 
36
  ```python
 
37
  from transformers import AutoModelForCausalLM, AutoTokenizer
38
 
39
- model_id = "ComputationalLinguisticsLab/LexisLM-1B-Instruct"
40
  tokenizer = AutoTokenizer.from_pretrained(model_id)
41
- model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto")
42
- messages = [{"role": "user", "content": "Ποια είναι η πρωτεύουσα της Ελλάδας;"}]
 
 
43
  inputs = tokenizer.apply_chat_template(
44
  messages, add_generation_prompt=True, tokenize=True,
45
  return_tensors="pt", return_dict=True,
46
- ).to(model.device)
47
- output = model.generate(**inputs, max_new_tokens=128)
 
 
 
 
 
 
 
48
  print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
49
  ```
50
 
 
 
 
 
 
 
51
  ## Evaluation
52
 
53
 
 
9
  - text-generation
10
  - instruction-tuned
11
  - llama
12
+ base_model: Konstantinos/LexisLM-1B
13
  ---
14
 
15
  # LexisLM-1B-Instruct
 
34
  ## Usage
35
 
36
  ```python
37
+ import torch
38
  from transformers import AutoModelForCausalLM, AutoTokenizer
39
 
40
+ model_id = "ComputationalLinguisticsPlatform/LexisLM-1B-Instruct"
41
  tokenizer = AutoTokenizer.from_pretrained(model_id)
42
+ torch.set_num_threads(4)
43
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32)
44
+ torch.manual_seed(42)
45
+ messages = [{"role": "user", "content": "Η πρωτεύουσα της Ελλάδας είναι"}]
46
  inputs = tokenizer.apply_chat_template(
47
  messages, add_generation_prompt=True, tokenize=True,
48
  return_tensors="pt", return_dict=True,
49
+ )
50
+ inputs = {key: value.to(model.device) for key, value in inputs.items()
51
+ if key in ("input_ids", "attention_mask")}
52
+ output = model.generate(
53
+ **inputs, max_new_tokens=64, do_sample=True, temperature=0.1, top_p=0.9,
54
+ eos_token_id=[tokenizer.eos_token_id,
55
+ tokenizer.convert_tokens_to_ids("<|endofturn|>")],
56
+ pad_token_id=tokenizer.pad_token_id,
57
+ )
58
  print(tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
59
  ```
60
 
61
+ Output from this example (CPU FP32, seed 42):
62
+
63
+ ```text
64
+ Η Αθήνα είναι η πρωτεύουσα της Ελλάδας από το 1834.
65
+ ```
66
+
67
  ## Evaluation
68
 
69