Views
No views yet

tinyllama-colorist-lora-v0.3, is a fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat-v0.3 on the color dataset.<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant\n{answer}<|im_end|>\nUser Input: Give me a sky blue color.
LLM response: #6092ff1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
3from transformers import pipeline
4
5def print_color_space(hex_color):
6 def hex_to_rgb(hex_color):
7 hex_color = hex_color.lstrip('#')
8 return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
9 r, g, b = hex_to_rgb(hex_color)
10 print(f'{hex_color}: \033[48;2;{r};{g};{b}m \033[0m')
11
12tokenizer = AutoTokenizer.from_pretrained(model_id_colorist_final)
13pipe = pipeline(
14 "text-generation",
15 model=model_id_colorist_final,
16 torch_dtype=torch.float16,
17 device_map="auto",
18)
19
20from time import perf_counter
21start_time = perf_counter()
22
23prompt = formatted_prompt('give me a pure brown color')
24sequences = pipe(
25 prompt,
26 do_sample=True,
27 temperature=0.1,
28 top_p=0.9,
29 num_return_sequences=1,
30 eos_token_id=tokenizer.eos_token_id,
31 max_new_tokens=12
32)
33for seq in sequences:
34 print(f"Result: {seq['generated_text']}")
35
36output_time = perf_counter() - start_time
37print(f"Time taken for inference: {round(output_time,2)} seconds")