Skip to content

Commit 2b25488

Browse files
committed
docs: add missing __main__ module test in examples in docs
1 parent 6b5e733 commit 2b25488

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

docs/en/advance/spec_decoding.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,11 @@ gen_config = GenerationConfig(
149149
response_format=dict(type='json_schema', json_schema=dict(name='person', schema=schema)),
150150
max_new_tokens=256,
151151
)
152-
response = pipe(['Introduce yourself as JSON.'], gen_config=gen_config)
153-
print(response)
152+
153+
if __name__ == '__main__':
154+
155+
response = pipe(['Introduce yourself as JSON.'], gen_config=gen_config)
156+
print(response)
154157
```
155158

156159
### api_server
@@ -181,12 +184,14 @@ schema = {
181184
}
182185
response_format = dict(type='json_schema', json_schema=dict(name='person', schema=schema))
183186

184-
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:24545/v1')
185-
model_name = client.models.list().data[0].id
186-
response = client.chat.completions.create(
187-
model=model_name,
188-
messages=[{'role': 'user', 'content': 'Introduce yourself as JSON.'}],
189-
response_format=response_format,
190-
)
191-
print(response)
187+
if __name__ == '__main__':
188+
189+
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:24545/v1')
190+
model_name = client.models.list().data[0].id
191+
response = client.chat.completions.create(
192+
model=model_name,
193+
messages=[{'role': 'user', 'content': 'Introduce yourself as JSON.'}],
194+
response_format=response_format,
195+
)
196+
print(response)
192197
```

docs/zh_cn/advance/spec_decoding.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ gen_config = GenerationConfig(
148148
response_format=dict(type='json_schema', json_schema=dict(name='person', schema=schema)),
149149
max_new_tokens=256,
150150
)
151-
response = pipe(['请用 JSON 格式做自我介绍。'], gen_config=gen_config)
152-
print(response)
151+
152+
if __name__ == '__main__':
153+
154+
response = pipe(['请用 JSON 格式做自我介绍。'], gen_config=gen_config)
155+
print(response)
153156
```
154157

155158
### api_server
@@ -180,12 +183,14 @@ schema = {
180183
}
181184
response_format = dict(type='json_schema', json_schema=dict(name='person', schema=schema))
182185

183-
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:24545/v1')
184-
model_name = client.models.list().data[0].id
185-
response = client.chat.completions.create(
186-
model=model_name,
187-
messages=[{'role': 'user', 'content': '请用 JSON 格式做自我介绍。'}],
188-
response_format=response_format,
189-
)
190-
print(response)
186+
if __name__ == '__main__':
187+
188+
client = OpenAI(api_key='YOUR_API_KEY', base_url='http://0.0.0.0:24545/v1')
189+
model_name = client.models.list().data[0].id
190+
response = client.chat.completions.create(
191+
model=model_name,
192+
messages=[{'role': 'user', 'content': '请用 JSON 格式做自我介绍。'}],
193+
response_format=response_format,
194+
)
195+
print(response)
191196
```

lmdeploy/pytorch/spec_decode/spec_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def _forward_impl(self, inputs: ModelInputs):
653653
output = self.proposer._forward(inputs, cache_engine=self.cache_engine)
654654
return output
655655

656-
async def async_sampling_logits(self, model_inputs: 'ModelInputs', extra_inputs: ARSpecExtraInputs,
656+
async def async_sampling_logits(self, model_inputs: ModelInputs, extra_inputs: ARSpecExtraInputs,
657657
sampling_inputs: SamplingInputs):
658658
"""Sample target logits and run rejection sampling."""
659659
with record_function('spec_rejection_sampling'):

0 commit comments

Comments
 (0)