Yazhou Cao commited on
Commit
8399353
1 Parent(s): eca46f1

added example in README

Browse files
Files changed (1) hide show
  1. README.md +39 -1
README.md CHANGED
@@ -8,6 +8,44 @@ license: apache-2.0
8
 
9
  # LLaVA Model Card
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ## Model details
12
 
13
  **Model type:**
@@ -42,4 +80,4 @@ The primary intended users of the model are researchers and hobbyists in compute
42
  - 40K ShareGPT data.
43
 
44
  ## Evaluation dataset
45
- A collection of 12 benchmarks, including 5 academic VQA benchmarks and 7 recent benchmarks specifically proposed for instruction-following LMMs.
 
8
 
9
  # LLaVA Model Card
10
 
11
+ ## SGLang
12
+ This contains the necessary files to run LLaVA-1.6 34B on SGLang. You can run the server with the following command:
13
+
14
+ `python -m sglang.launch_server --model-path dillonlaird/hf-llava-v1.6-34b --port 30000`
15
+
16
+ There seems to be issues with the chat formatting when using the sglang interface so I recommend querying the server directly and formatting the string yourself:
17
+
18
+ ```python
19
+ import requests
20
+ from transformers import AutoTokenizer
21
+
22
+
23
+ def generate(image_path: str, prompt: str, tokenizer):
24
+ chat = [
25
+ {"role": "system", "content": "Answer the question."},
26
+ {"role": "user", "content": "<image>\n" + prompt},
27
+ ]
28
+ chat_str = tokenizer.apply_chat_template(chat, tokenize=False)
29
+ chat_str += "<|img_start|>assistant\n"
30
+ sampling_params = {"temperature": 0.2, "max_new_tokens": 1536}
31
+ res = requests.post(
32
+ "http://localhost:30000/generate",
33
+ json={
34
+ "text": chat_str,
35
+ "image_data": image_path,
36
+ "sampling_params": sampling_params,
37
+ },
38
+ )
39
+ return res.json()["text"]
40
+
41
+
42
+ if __name__ == "__main__":
43
+ tokenizer = AutoTokenizer.from_pretrained("liuhaotian/llava-v1.6-34b")
44
+ image_path = "path/to/image.jpg"
45
+ prompt = "What is the name of the mountain?"
46
+ desc = generate(image_path, prompt, tokenizer)
47
+ ```
48
+
49
  ## Model details
50
 
51
  **Model type:**
 
80
  - 40K ShareGPT data.
81
 
82
  ## Evaluation dataset
83
+ A collection of 12 benchmarks, including 5 academic VQA benchmarks and 7 recent benchmarks specifically proposed for instruction-following LMMs.