Skip to content

Commit 055c844

Browse files
committed
Update Blog “using-structured-outputs-in-vllm”
1 parent e0fef43 commit 055c844

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

content/blog/using-structured-outputs-in-vllm.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ tags:
1010
- opensource
1111
- LLM
1212
---
13+
## Using structured outputs in vLLM
1314
Generating predictable and reliable outputs from large language models (LLMs) can be challenging, especially when those outputs need to integrate seamlessly with downstream systems. Structured outputs solve this problem by enforcing specific formats, such as JSON, regex patterns, or even grammars. vLLM supported this since some time ago, but there were no documentation on how to use it, and that´s why I decided to do a contribution and write the Structured Outputs documentation page (https://docs.vllm.ai/en/latest/usage/structured_outputs.html).
1415

15-
# Why Structured Outputs?
16+
### Why Structured Outputs?
1617

1718
LLMs are incredibly powerful, but their outputs can be inconsistent when a specific format is required. Structured outputs address this issue by restricting the model’s generated text to adhere to predefined rules or formats, ensuring:
1819

@@ -24,7 +25,7 @@ Imagine we have an external system which receives a JSON with the all the detail
2425

2526
How these tools work? The idea is that we´ll be able to filter the list of possible next tokens to force that we are always generating a token that is valid for the desired output format.
2627

27-
# What is vLLM?
28+
### What is vLLM?
2829

2930
vLLM is a state-of-the-art, open-source inference and serving engine for LLMs. It’s built for performance and simplicity, offering:
3031

@@ -34,7 +35,7 @@ vLLM is a state-of-the-art, open-source inference and serving engine for LLMs. I
3435

3536
These optimizations make vLLM one of the fastest and most versatile engines for production environments.
3637

37-
# Structured outputs on vLLM
38+
### Structured outputs on vLLM
3839

3940
vLLM extends the OpenAI API with additional parameters to enable structured outputs. These include:
4041

@@ -45,7 +46,7 @@ vLLM extends the OpenAI API with additional parameters to enable structured outp
4546

4647
Here’s how each works, along with example outputs:
4748

48-
### **1. Guided Choice**
49+
#### **1. Guided Choice**
4950

5051
Simplest form of structured output, ensuring the response is one of a set of predefined options.
5152

@@ -70,7 +71,7 @@ print(completion.choices[0].message.content)
7071
positive
7172
```
7273

73-
### **2. Guided Regex**
74+
#### **2. Guided Regex**
7475

7576
Constrains output to match a regex pattern, useful for formats like email addresses.
7677

@@ -94,7 +95,7 @@ print(completion.choices[0].message.content)
9495
9596
```
9697

97-
### **3. Guided JSON**
98+
#### **3. Guided JSON**
9899

99100
Enforces a valid JSON format based on a schema, simplifying integration with other systems.
100101

@@ -135,7 +136,7 @@ print(completion.choices[0].message.content)
135136
}
136137
```
137138

138-
### **4. Guided Grammar**
139+
#### **4. Guided Grammar**
139140

140141
Uses an EBNF grammar to define complex output structures, such as SQL queries.
141142

@@ -163,7 +164,7 @@ print(completion.choices[0].message.content)
163164
SELECT * FROM users WHERE age > 30;
164165
```
165166

166-
# **Next Steps**
167+
### **Next Steps**
167168

168169
To start integrating structured outputs into your projects:
169170

0 commit comments

Comments
 (0)