ferran-espuna commited on
Commit
7c490b6
·
verified ·
1 Parent(s): 08da042

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -1
README.md CHANGED
@@ -63,7 +63,38 @@ This model card corresponds to the fp8-quantized version of Salamandra-7b-instru
63
  The entire Salamandra family is released under a permissive [Apache 2.0 license]((https://www.apache.org/licenses/LICENSE-2.0)).
64
 
65
 
66
- ## Additional information
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  ### Author
69
  International Business Machines (IBM).
 
63
  The entire Salamandra family is released under a permissive [Apache 2.0 license]((https://www.apache.org/licenses/LICENSE-2.0)).
64
 
65
 
66
+ ## Additional information## How to Use
67
+
68
+ The following example code works under ``Python 3.9.16``, ``vllm==0.6.3.post1``, ``torch==2.4.0`` and ``torchvision==0.19.0``, though it should run on
69
+ any current version of the libraries. This is an example of a conversational chatbot using the model:
70
+
71
+ ```
72
+ from vllm import LLM, SamplingParams
73
+
74
+ model_name = "BSC-LT/salamandra-7b-instruct-fp8"
75
+ llm = LLM(model=model_name)
76
+
77
+ messages = []
78
+
79
+ while True:
80
+ user_input = input("user >> ")
81
+ if user_input.lower() == "exit":
82
+ print("Chat ended.")
83
+ break
84
+
85
+ messages.append({'role': 'user', 'content': user_input})
86
+
87
+ outputs = llm.chat(messages,
88
+ sampling_params=SamplingParams(
89
+ temperature=0.5,
90
+ stop_token_ids=[5],
91
+ max_tokens=200)
92
+ )[0].outputs
93
+
94
+ model_output = outputs[0].text
95
+ print(f'assistant >> {model_output}')
96
+ messages.append({'role': 'assistant', 'content': model_output})
97
+ ```
98
 
99
  ### Author
100
  International Business Machines (IBM).