mychen76 commited on
Commit
ff992cf
1 Parent(s): 8d90af0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +59 -0
README.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ Model: "mychen76/tinyllama-colorist-v2" - is a finetuned TinyLlama model using color dataset.
5
+ Dataset: "burkelibbey/colors"
6
+
7
+ PROMPT FORMAT:
8
+ "<|im_start|>user\n{question}<|im_end|>\n<|im_start|>assistant:""
9
+
10
+ MODEL USAGE:
11
+ ```python
12
+ import torch
13
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
14
+ from transformers import pipeline
15
+
16
+ def print_color_space(hex_color):
17
+ def hex_to_rgb(hex_color):
18
+ hex_color = hex_color.lstrip('#')
19
+ return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
20
+ r, g, b = hex_to_rgb(hex_color)
21
+ print(f'{hex_color}: \033[48;2;{r};{g};{b}m \033[0m')
22
+
23
+ tokenizer = AutoTokenizer.from_pretrained(model_id_colorist_final)
24
+ pipe = pipeline(
25
+ "text-generation",
26
+ model=model_id_colorist_final,
27
+ torch_dtype=torch.float16,
28
+ device_map="auto",
29
+ )
30
+
31
+ from time import perf_counter
32
+ start_time = perf_counter()
33
+
34
+ prompt = formatted_prompt('give me a pure brown color')
35
+ sequences = pipe(
36
+ prompt,
37
+ do_sample=True,
38
+ temperature=0.1,
39
+ top_p=0.9,
40
+ num_return_sequences=1,
41
+ eos_token_id=tokenizer.eos_token_id,
42
+ max_new_tokens=12
43
+ )
44
+ for seq in sequences:
45
+ print(f"Result: {seq['generated_text']}")
46
+
47
+ output_time = perf_counter() - start_time
48
+ print(f"Time taken for inference: {round(output_time,2)} seconds")
49
+
50
+ ```
51
+ result:
52
+ ```
53
+ Result: <|im_start|>user
54
+ give me a pure brown color<|im_end|>
55
+ <|im_start|>assistant: #807070<|im_end>
56
+
57
+ Time taken for inference: 0.19 seconds
58
+ ```
59
+