MoritzLaurer HF staff commited on
Commit
07312aa
1 Parent(s): 20d0a39

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -1
README.md CHANGED
@@ -4,6 +4,7 @@ tags:
4
  - prompt
5
  ---
6
 
 
7
 
8
  This repo illustrates how you can use the `hf_hub_prompts` library to load prompts from YAML files in open-weight model repositories.
9
  Several open-weight models have been tuned on specific tasks with specific prompts.
@@ -12,9 +13,13 @@ To elicit this capability, users need to use this special prompt: `Please provid
12
 
13
  These these kinds of task-specific special prompts are currently unsystematically reported in model cards, github repos, .txt files etc.
14
 
15
- The hf_hub_prompts library standardises the sharing of prompts in YAML files.
 
16
 
 
17
 
 
 
18
  ```py
19
  #!pip install hf_hub_prompts
20
  from hf_hub_prompts import download_prompt
@@ -36,6 +41,25 @@ print(messages)
36
  # }]
37
  ```
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  These populated prompts in the OpenAI messages format are then directly compatible with vLLM or TGI containers.
40
  When you host one of these containers on a HF Endpoint, for example, you can call on the model with the OpenAI client or with the HF Interence Client.
41
 
 
4
  - prompt
5
  ---
6
 
7
+ ## Sharing special prompts of open-weight models
8
 
9
  This repo illustrates how you can use the `hf_hub_prompts` library to load prompts from YAML files in open-weight model repositories.
10
  Several open-weight models have been tuned on specific tasks with specific prompts.
 
13
 
14
  These these kinds of task-specific special prompts are currently unsystematically reported in model cards, github repos, .txt files etc.
15
 
16
+ The hf_hub_prompts library standardises the sharing of prompts in YAML files.
17
+ I recommend sharing these these special prompts directly in the model repository of the respective.
18
 
19
+ Below is an example for the InternVL2 model.
20
 
21
+
22
+ #### Prompt for extracting bounding boxes of specific objects of interest with InternVL2
23
  ```py
24
  #!pip install hf_hub_prompts
25
  from hf_hub_prompts import download_prompt
 
41
  # }]
42
  ```
43
 
44
+ #### Prompt for extracting bounding boxes of any object in an image with InternVL2
45
+ ```py
46
+ # download image prompt template
47
+ prompt_template = download_prompt(repo_id="MoritzLaurer/open_models_special_prompts", filename="internvl2-objectdetection-prompt.yaml")
48
+
49
+ # populate prompt
50
+ image_url = "https://unsplash.com/photos/ZVw3HmHRhv0/download?ixid=M3wxMjA3fDB8MXxhbGx8NHx8fHx8fDJ8fDE3MjQ1NjAzNjl8&force=true&w=1920"
51
+ messages = prompt_template.format_messages(image_url=image_url, client="openai")
52
+
53
+ print(messages)
54
+ # [{'role': 'user',
55
+ # 'content': [{'type': 'image_url',
56
+ # 'image_url': {'url': 'https://unsplash.com/photos/ZVw3HmHRhv0/download?ixid=M3wxMjA3fDB8MXxhbGx8NHx8fHx8fDJ8fDE3MjQ1NjAzNjl8&force=true&w=1920'}},
57
+ # {'type': 'text',
58
+ # 'text': 'Please detect and label all objects in the following image and mark their positions.'}]}]
59
+ ```
60
+
61
+ #### Using the prompt with an open inference container like vLLM or TGI
62
+
63
  These populated prompts in the OpenAI messages format are then directly compatible with vLLM or TGI containers.
64
  When you host one of these containers on a HF Endpoint, for example, you can call on the model with the OpenAI client or with the HF Interence Client.
65