Views
No views yet
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.1994 | 1.0 | 2480 | 1.1954 |
| 1.0039 | 2.0 | 4960 | 1.0974 |
| 0.6836 | 3.0 | 7440 | 1.1356 |
1
2# Install transformers from source - only needed for versions <= v4.34
3# pip install git+https://github.com/huggingface/transformers.git
4# pip install accelerate
5
6import torch
7from transformers import pipeline
8
9pipe = pipeline("text-generation", model="
10zephyr-7b-gemma-sft-african-ultrachat-5k", torch_dtype=torch.bfloat16, device_map="auto")
11
12# We use the tokenizer's chat template to format each message - see https://huggingface.co/docs/transformers/main/en/chat_templating
13messages = [
14 {
15 "role": "system",
16 "content": "You are a friendly chatbot who answewrs question in given language",
17 },
18 {"role": "user", "content": "what is the 3 biggest countrys in Africa?"},
19]
20prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
22print(outputs[0]["generated_text"])
23# <|system|>
24# You are a friendly chatbot who always responds in the style of a pirate<eos>
25# <|user|>
26# what is the 3 biggest countrys in Africa?<eos>
27# <|assistant|>
28# The 3 biggest countries in Africa are Nigeria, Ethiopia and South Africa.1
2import torch
3from transformers import pipeline
4from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
5
6
7quantization_config = BitsAndBytesConfig(load_in_4bit=True)
8
9tokenizer = AutoTokenizer.from_pretrained("
10zephyr-7b-gemma-sft-african-ultrachat-5k")
11model = AutoModelForCausalLM.from_pretrained("
12zephyr-7b-gemma-sft-african-ultrachat-5k", quantization_config=quantization_config)
13
14
15pipe = pipeline("text-generation", model=model,tokenizer=tokenizer, torch_dtype=torch.bfloat16, device_map="auto")
16
17messages = [
18 {
19 "role": "system",
20 "content": "You are a friendly chatbot who answewrs question in given language",
21 },
22 {"role": "user", "content": "list languages in Africa?"},
23]
24prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
25outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
26print(outputs[0]["generated_text"])
27