Skip to content

Commit 9f63ee5

Browse files
committed
docs: fix example codes
1 parent 18c355d commit 9f63ee5

2 files changed

Lines changed: 62 additions & 62 deletions

File tree

docs/en/advance/spec_decoding.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -129,29 +129,29 @@ When the draft model uses a different vocabulary from the target model (e.g. Eag
129129
from lmdeploy import PytorchEngineConfig, pipeline
130130
from lmdeploy.messages import GenerationConfig, SpeculativeConfig
131131

132-
model_path = 'deepseek-ai/DeepSeek-V3'
133-
spec_cfg = SpeculativeConfig(method='deepseek_mtp', num_speculative_tokens=3)
134-
pipe = pipeline(
135-
model_path,
136-
backend_config=PytorchEngineConfig(tp=16, max_batch_size=128),
137-
speculative_config=spec_cfg,
138-
)
139-
140-
schema = {
141-
'type': 'object',
142-
'properties': {
143-
'name': {'type': 'string'},
144-
'age': {'type': 'integer'},
145-
},
146-
'required': ['name', 'age'],
147-
}
148-
gen_config = GenerationConfig(
149-
response_format=dict(type='json_schema', json_schema=dict(name='person', schema=schema)),
150-
max_new_tokens=256,
151-
)
152-
153132
if __name__ == '__main__':
154133

134+
model_path = 'deepseek-ai/DeepSeek-V3'
135+
spec_cfg = SpeculativeConfig(method='deepseek_mtp', num_speculative_tokens=3)
136+
pipe = pipeline(
137+
model_path,
138+
backend_config=PytorchEngineConfig(tp=16, max_batch_size=128),
139+
speculative_config=spec_cfg,
140+
)
141+
142+
schema = {
143+
'type': 'object',
144+
'properties': {
145+
'name': {'type': 'string'},
146+
'age': {'type': 'integer'},
147+
},
148+
'required': ['name', 'age'],
149+
}
150+
gen_config = GenerationConfig(
151+
response_format=dict(type='json_schema', json_schema=dict(name='person', schema=schema)),
152+
max_new_tokens=256,
153+
)
154+
155155
response = pipe(['Introduce yourself as JSON.'], gen_config=gen_config)
156156
print(response)
157157
```
@@ -174,18 +174,18 @@ The client can then use `response_format` as described in the [structured output
174174
```python
175175
from openai import OpenAI
176176

177-
schema = {
178-
'type': 'object',
179-
'properties': {
180-
'name': {'type': 'string'},
181-
'age': {'type': 'integer'},
182-
},
183-
'required': ['name', 'age'],
184-
}
185-
response_format = dict(type='json_schema', json_schema=dict(name='person', schema=schema))
186-
187177
if __name__ == '__main__':
188178

179+
schema = {
180+
'type': 'object',
181+
'properties': {
182+
'name': {'type': 'string'},
183+
'age': {'type': 'integer'},
184+
},
185+
'required': ['name', 'age'],
186+
}
187+
response_format = dict(type='json_schema', json_schema=dict(name='person', schema=schema))
188+
189189
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:24545/v1')
190190
model_name = client.models.list().data[0].id
191191
response = client.chat.completions.create(

docs/zh_cn/advance/spec_decoding.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,29 @@ deepseek-ai/DeepSeek-V3 \
128128
from lmdeploy import PytorchEngineConfig, pipeline
129129
from lmdeploy.messages import GenerationConfig, SpeculativeConfig
130130

131-
model_path = 'deepseek-ai/DeepSeek-V3'
132-
spec_cfg = SpeculativeConfig(method='deepseek_mtp', num_speculative_tokens=3)
133-
pipe = pipeline(
134-
model_path,
135-
backend_config=PytorchEngineConfig(tp=16, max_batch_size=128),
136-
speculative_config=spec_cfg,
137-
)
138-
139-
schema = {
140-
'type': 'object',
141-
'properties': {
142-
'name': {'type': 'string'},
143-
'age': {'type': 'integer'},
144-
},
145-
'required': ['name', 'age'],
146-
}
147-
gen_config = GenerationConfig(
148-
response_format=dict(type='json_schema', json_schema=dict(name='person', schema=schema)),
149-
max_new_tokens=256,
150-
)
151-
152131
if __name__ == '__main__':
153132

133+
model_path = 'deepseek-ai/DeepSeek-V3'
134+
spec_cfg = SpeculativeConfig(method='deepseek_mtp', num_speculative_tokens=3)
135+
pipe = pipeline(
136+
model_path,
137+
backend_config=PytorchEngineConfig(tp=16, max_batch_size=128),
138+
speculative_config=spec_cfg,
139+
)
140+
141+
schema = {
142+
'type': 'object',
143+
'properties': {
144+
'name': {'type': 'string'},
145+
'age': {'type': 'integer'},
146+
},
147+
'required': ['name', 'age'],
148+
}
149+
gen_config = GenerationConfig(
150+
response_format=dict(type='json_schema', json_schema=dict(name='person', schema=schema)),
151+
max_new_tokens=256,
152+
)
153+
154154
response = pipe(['请用 JSON 格式做自我介绍。'], gen_config=gen_config)
155155
print(response)
156156
```
@@ -173,18 +173,18 @@ deepseek-ai/DeepSeek-V3 \
173173
```python
174174
from openai import OpenAI
175175

176-
schema = {
177-
'type': 'object',
178-
'properties': {
179-
'name': {'type': 'string'},
180-
'age': {'type': 'integer'},
181-
},
182-
'required': ['name', 'age'],
183-
}
184-
response_format = dict(type='json_schema', json_schema=dict(name='person', schema=schema))
185-
186176
if __name__ == '__main__':
187177

178+
schema = {
179+
'type': 'object',
180+
'properties': {
181+
'name': {'type': 'string'},
182+
'age': {'type': 'integer'},
183+
},
184+
'required': ['name', 'age'],
185+
}
186+
response_format = dict(type='json_schema', json_schema=dict(name='person', schema=schema))
187+
188188
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:24545/v1')
189189
model_name = client.models.list().data[0].id
190190
response = client.chat.completions.create(

0 commit comments

Comments
 (0)