Views
No views yet
| P. | Arch. | Act. | V. | H. | I. | L. | A.H. | K.H. | Tie | |
|---|---|---|---|---|---|---|---|---|---|---|
| XXL2 | 102 | LLaMA | SwiGLU | 16K | 1120 | 3072 | 6 | 16 | 8 | True |
| XXL | 100 | LLaMA | SwiGLU | 16K | 768 | 4096 | 8 | 24 | 8 | True |
| XL | 78 | LLaMA | GeGLU | 16K | 768 | 4096 | 6 | 24 | 8 | True |
| L | 49 | LLaMA | GeGLU | 16K | 512 | 2816 | 8 | 16 | 8 | True |
| M2 | 22 | Qwen2 | GeGLU | 4K | 432 | 2304 | 6 | 24 | 8 | True |
| M | 22 | LLaMA | SwiGLU | 8K | 256 | 1408 | 16 | 16 | 4 | True |
| S | 9 | LLaMA | SwiGLU | 4K | 168 | 896 | 16 | 12 | 4 | True |
| XS | 2 | LLaMA | SwiGLU | 2K | 96 | 512 | 12 | 12 | 4 | True |
<|im_start|> {English Text} <|endoftext|>1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_path = 'Mxode/NanoTranslator-XL'
5
6tokenizer = AutoTokenizer.from_pretrained(model_path)
7model = AutoModelForCausalLM.from_pretrained(model_path)
8
9def translate(text: str, model, **kwargs):
10 generation_args = dict(
11 max_new_tokens = kwargs.pop("max_new_tokens", 512),
12 do_sample = kwargs.pop("do_sample", True),
13 temperature = kwargs.pop("temperature", 0.55),
14 top_p = kwargs.pop("top_p", 0.8),
15 top_k = kwargs.pop("top_k", 40),
16 **kwargs
17 )
18
19 prompt = "<|im_start|>" + text + "<|endoftext|>"
20 model_inputs = tokenizer([prompt], return_tensors="pt").to(model.device)
21
22 generated_ids = model.generate(model_inputs.input_ids, **generation_args)
23 generated_ids = [
24 output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
25 ]
26
27 response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
28 return response
29
30text = "Each step of the cell cycle is monitored by internal."
31
32response = translate(text, model, max_new_tokens=64, do_sample=False)
33print(response)1from optimum.onnxruntime import ORTModelForCausalLM
2from transformers import AutoTokenizer
3
4model_path = "your/folder/to/onnx_model"
5
6ort_model = ORTModelForCausalLM.from_pretrained(model_path)
7tokenizer = AutoTokenizer.from_pretrained(model_path)
8
9text = "Each step of the cell cycle is monitored by internal."
10
11response = translate(text, ort_model, max_new_tokens=64, do_sample=False)
12print(response)1from optimum.pipelines import pipeline
2
3model_path = "your/folder/to/onnx_model"
4pipe = pipeline("text-generation", model=model_path, accelerator="ort")
5
6text = "Each step of the cell cycle is monitored by internal."
7
8response = pipe(text, max_new_tokens=64, do_sample=False)
9response