ereniko commited on
Commit
4dd335d
·
verified ·
1 Parent(s): 708dccc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -2
README.md CHANGED
@@ -97,9 +97,17 @@ None of the benchmarks above directly test whether the model's writing holds tog
97
 
98
  **Prompt:** "Once upon a time, there was a"
99
 
100
- > Once upon a time, there was a man named Peter who lived in a beautiful country called Ireland. His father was a wise old man who was known for his knowledge of geometry. One day, a young girl named Alice came to visit Peter in Ireland. As they walked together, Alice met a boy named Leo, who had big shoes and a big hat. Alice asked him, "What are you doing with that, dear?" Peter told Alice about a time when he was a boy. He was still trying to understand how things worked. One day, a clever fox came to Peter and asked him how he could have fun. Peter smiled and said, "That's because he learned to ride an imaginary plane!" Alice watched as Peter explained how he learned how to climb trees and follow a river. "You've come to know that, Peter," she said, and Emmanuel smiled. They sat down together and talked about their favorite things, like building a bridge to reach a friend and helping a neighbor.
101
 
102
- There is an actual through line here. Peter gets introduced with a name and a place, Alice arrives and has a real interaction with him, a fox shows up mid story and gets a response, and the ending calls back to the "learning" theme set up in the first sentence. It is not perfectly logical throughout, but it tracks entities and builds toward something across sentences, which is exactly what v1 could not do.
 
 
 
 
 
 
 
 
103
 
104
  ---
105
 
@@ -148,6 +156,71 @@ Custom byte-level BPE tokenizer trained from scratch on a sample of the pretrain
148
 
149
  ---
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  ## Limitations
152
 
153
  - Base model only, not instruction tuned, will not follow instructions or answer questions
 
97
 
98
  **Prompt:** "Once upon a time, there was a"
99
 
100
+ > Once upon a time, there was a wise old turtle named Timmy who lived on the coast of South America. In this magical place, no matter how big or large, people could look up at the sea and talk to each other.
101
 
102
+ Timmy asked, "What do you mean, Timmy?"
103
+
104
+ The turtle replied, "Well, I think you might see people talking about ocean creatures. They are like little waves that carry their voices. Sometimes they say they're too big or small to hear."
105
+
106
+ After a few moments, Timmy had an idea. "Can we go on a boat-boat tour? I can't believe all the kids in the village are doing that!"
107
+
108
+ As they sailed further, they saw many beautiful islands and vibrant colors. Each island had its unique culture and traditions. When they reached the top, they saw a group of kids playing and splashing around.
109
+
110
+ "Wow, lookgies!" said Timmy. "They live in a big ocean full of colorful fish and
111
 
112
  ---
113
 
 
156
 
157
  ---
158
 
159
+ ## Inference
160
+
161
+ Here's a basic inference code you can run to immediately start using İvme-Conversate-v2-Base
162
+
163
+ ```python
164
+ import sys
165
+ import torch
166
+ from tokenizers import Tokenizer
167
+ from huggingface_hub import hf_hub_download, snapshot_download
168
+
169
+ repo_id = "IvmeLabs/Ivme-Conversate-v2-Base"
170
+
171
+ # Download just the model/ folder (architecture code) into the HF cache,
172
+ # then add it to sys.path so `from model import ...` works without the
173
+ # user needing to manually copy any files.
174
+ repo_local_dir = snapshot_download(repo_id, allow_patterns=["model/*"])
175
+ sys.path.append(repo_local_dir)
176
+
177
+ from model import IvmeConfig, IvmeConversateV2
178
+
179
+ ckpt_path = hf_hub_download(repo_id, "ckpt_final.pt")
180
+ tokenizer_path = hf_hub_download(repo_id, "tokenizer.json")
181
+
182
+ tokenizer = Tokenizer.from_file(tokenizer_path)
183
+
184
+ # IvmeConfig is a plain dataclass saved into the checkpoint. Trust this only
185
+ # because it's our own checkpoint, produced by our own training code.
186
+ torch.serialization.add_safe_globals([IvmeConfig])
187
+ ckpt = torch.load(ckpt_path, map_location="cuda")
188
+ cfg = ckpt["config"]
189
+
190
+ model = IvmeConversateV2(cfg)
191
+
192
+ # Use EMA weights (smoothed), not the raw training weights, for inference.
193
+ # Strip torch.compile's "_orig_mod." prefix if the checkpoint was compiled.
194
+ state_dict = ckpt["ema_state_dict"]
195
+ state_dict = {k.removeprefix("_orig_mod."): v for k, v in state_dict.items()}
196
+ model.load_state_dict(state_dict)
197
+
198
+ model.cuda().eval()
199
+
200
+ prompt = "Once upon a time, there was a"
201
+ ids = tokenizer.encode(prompt).ids
202
+ idx = torch.tensor([ids], dtype=torch.long, device="cuda")
203
+
204
+ eot_id = tokenizer.token_to_id("<|endoftext|>")
205
+ with torch.no_grad():
206
+ for _ in range(200):
207
+ idx_cond = idx if idx.size(1) <= cfg.context_len else idx[:, -cfg.context_len:]
208
+ logits, _ = model(idx_cond)
209
+ logits = logits[:, -1, :] / 0.8 # temperature
210
+
211
+ v, _ = torch.topk(logits, 50)
212
+ logits[logits < v[:, [-1]]] = -float("inf")
213
+
214
+ probs = torch.softmax(logits, dim=-1)
215
+ next_id = torch.multinomial(probs, num_samples=1)
216
+ idx = torch.cat([idx, next_id], dim=1)
217
+
218
+ if next_id.item() == eot_id:
219
+ break
220
+
221
+ print(tokenizer.decode(idx[0].tolist()))
222
+ ```
223
+
224
  ## Limitations
225
 
226
  - Base model only, not instruction tuned, will not follow instructions or answer questions