funmaker commited on
Commit
8a9ad75
·
1 Parent(s): 3d00c3d

Enhance README with sampling parameter recommendations and Llama.cpp usage examples

Browse files
Files changed (2) hide show
  1. README-cn.md +27 -2
  2. README.md +27 -2
README-cn.md CHANGED
@@ -268,6 +268,13 @@ MiniCPM5-2B 的训练过程是 **[UltraData 分级数据管理体系](https://ar
268
 
269
  ## 快速上手
270
 
 
 
 
 
 
 
 
271
  ### vLLM
272
 
273
  ```bash
@@ -316,6 +323,26 @@ python -m sglang.launch_server \
316
  --port 30000
317
  ```
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  ### Transformers
320
 
321
  ```bash
@@ -344,8 +371,6 @@ outputs = model.generate(**inputs, max_new_tokens=128)
344
  print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
345
  ```
346
 
347
- 推荐的采样参数:`temperature=1.0, top_p=0.95`
348
-
349
  ## 工具调用
350
 
351
  工具调用**推荐使用 SGLang**。MiniCPM5-2B 以 XML 格式产出工具调用,SGLang 内置的 `minicpm5` parser 会自动将其转换为 OpenAI 兼容的 `tool_calls` 字段。
 
268
 
269
  ## 快速上手
270
 
271
+ > [!Tip]
272
+ > 我们建议在生成时使用以下采样参数组合:`temperature=1.0, top_p=0.95, min_p=0.0`。
273
+ >
274
+ > 如果遇到重复输出,请尝试:`temperature=1.0, top_p=0.95, min_p=0.0, repetition_penalty=1.05`。
275
+ >
276
+ > 请注意,不同推理框架对采样参数的支持程度有所差异。
277
+
278
  ### vLLM
279
 
280
  ```bash
 
323
  --port 30000
324
  ```
325
 
326
+ ### Llama.cpp
327
+
328
+ ```bash
329
+ llama-server -m MiniCPM5-2B-F16.gguf -a MiniCPM5-2B --port 8080 -ngl 99 -c 8192 --jinja
330
+ ```
331
+
332
+ 在这个例子里 `-c 8192` 设置了上下文长度为 8192,可以根据需要修改上下文长度。
333
+
334
+ ```bash
335
+ curl http://localhost:8080/v1/chat/completions \
336
+ -H "Content-Type: application/json" \
337
+ -d '{
338
+ "model": "MiniCPM5-2B",
339
+ "messages": [{"role": "user", "content": "1+1=?"}],
340
+ "temperature": 1.0, "top_p": 0.95, "min_p": 0.0, "max_tokens": 256
341
+ }'
342
+ ```
343
+
344
+ llama.cpp 默认设置 `min_p=0.05`,会过滤掉概率低于最高概率 token 5% 的 token。这种过滤反而可能引发重复——它恰恰过滤掉了模型摆脱重复循环所需的那些 token。我们明确将 `min_p` 设为 `0.0` 以禁用该过滤。
345
+
346
  ### Transformers
347
 
348
  ```bash
 
371
  print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
372
  ```
373
 
 
 
374
  ## 工具调用
375
 
376
  工具调用**推荐使用 SGLang**。MiniCPM5-2B 以 XML 格式产出工具调用,SGLang 内置的 `minicpm5` parser 会自动将其转换为 OpenAI 兼容的 `tool_calls` 字段。
README.md CHANGED
@@ -279,6 +279,13 @@ During **post-training**, we proceed in three steps: **SFT**, **RL**, and **OPD*
279
 
280
  ## Quickstart
281
 
 
 
 
 
 
 
 
282
  ### vLLM
283
 
284
  ```bash
@@ -327,6 +334,26 @@ python -m sglang.launch_server \
327
  --port 30000
328
  ```
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  ### Transformers
331
 
332
  ```bash
@@ -355,8 +382,6 @@ outputs = model.generate(**inputs, max_new_tokens=128)
355
  print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
356
  ```
357
 
358
- Recommended sampling params: `temperature=1.0, top_p=0.95`
359
-
360
  ## Tool Calling
361
 
362
  For tool / function calling, **SGLang is the recommended backend**. MiniCPM5-2B emits XML-style tool calls and SGLang's built-in `minicpm5` parser converts them to OpenAI-compatible `tool_calls` natively:
 
279
 
280
  ## Quickstart
281
 
282
+ > [!Tip]
283
+ > We recommend using the following sets of sampling parameters for generation: `temperature=1.0, top_p=0.95, min_p=0.0`.
284
+ >
285
+ > If you encounter repetitive outputs, try: `temperature=1.0, top_p=0.95, min_p=0.0, repetition_penalty=1.05`.
286
+ >
287
+ > Please note that the support for sampling parameters varies according to inference frameworks.
288
+
289
  ### vLLM
290
 
291
  ```bash
 
334
  --port 30000
335
  ```
336
 
337
+ ### Llama.cpp
338
+
339
+ ```bash
340
+ llama-server -m MiniCPM5-2B-F16.gguf -a MiniCPM5-2B --port 8080 -ngl 99 -c 8192 --jinja
341
+ ```
342
+
343
+ `-c 8192` sets the context length. You can adjust this value as needed.
344
+
345
+ ```bash
346
+ curl http://localhost:8080/v1/chat/completions \
347
+ -H "Content-Type: application/json" \
348
+ -d '{
349
+ "model": "MiniCPM5-2B",
350
+ "messages": [{"role": "user", "content": "1+1=?"}],
351
+ "temperature": 1.0, "top_p": 0.95, "min_p": 0.0, "max_tokens": 256
352
+ }'
353
+ ```
354
+
355
+ In llama.cpp, the default `min_p=0.05` can lead to repetitive output: it filters out tokens whose probability is below 5% of the highest-probability token, potentially discarding the exact tokens needed to break out of a repetition loop. To prevent this, we set `min_p=0.0`.
356
+
357
  ### Transformers
358
 
359
  ```bash
 
382
  print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
383
  ```
384
 
 
 
385
  ## Tool Calling
386
 
387
  For tool / function calling, **SGLang is the recommended backend**. MiniCPM5-2B emits XML-style tool calls and SGLang's built-in `minicpm5` parser converts them to OpenAI-compatible `tool_calls` natively: