EddyGiusepe commited on
Commit
a9dd919
·
verified ·
1 Parent(s): 3de0b29

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +41 -0
README.md CHANGED
@@ -36,6 +36,47 @@ The model training process is similar to the regular Llama2 model with a chat pr
36
  User Input: Give me a sky blue color.
37
  LLM response: #6092ff
38
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  ### Training hyperparameters
41
 
 
36
  User Input: Give me a sky blue color.
37
  LLM response: #6092ff
38
  ```
39
+ ## <font color="yellow">Model usage</font>
40
+ ```
41
+ import torch
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
43
+ from transformers import pipeline
44
+
45
+ def print_color_space(hex_color):
46
+ def hex_to_rgb(hex_color):
47
+ hex_color = hex_color.lstrip('#')
48
+ return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
49
+ r, g, b = hex_to_rgb(hex_color)
50
+ print(f'{hex_color}: \033[48;2;{r};{g};{b}m \033[0m')
51
+
52
+ tokenizer = AutoTokenizer.from_pretrained(model_id_colorist_final)
53
+ pipe = pipeline(
54
+ "text-generation",
55
+ model=model_id_colorist_final,
56
+ torch_dtype=torch.float16,
57
+ device_map="auto",
58
+ )
59
+
60
+ from time import perf_counter
61
+ start_time = perf_counter()
62
+
63
+ prompt = formatted_prompt('give me a pure brown color')
64
+ sequences = pipe(
65
+ prompt,
66
+ do_sample=True,
67
+ temperature=0.1,
68
+ top_p=0.9,
69
+ num_return_sequences=1,
70
+ eos_token_id=tokenizer.eos_token_id,
71
+ max_new_tokens=12
72
+ )
73
+ for seq in sequences:
74
+ print(f"Result: {seq['generated_text']}")
75
+
76
+ output_time = perf_counter() - start_time
77
+ print(f"Time taken for inference: {round(output_time,2)} seconds")
78
+ ```
79
+
80
 
81
  ### Training hyperparameters
82