Text Generation
Transformers
Safetensors
Chinese
qwen3_5_text
rewrite2
novel-rewrite
novel-expansion
chinese
nvfp4
conversational
8-bit precision
modelopt
Run this model with HF Jobs
Run beileng/rewrite2-27b-nvfp4 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/beileng/rewrite2-27b-nvfp4. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/beileng/rewrite2-27b-nvfp4 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/beileng/rewrite2-27b-nvfp4. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/beileng/rewrite2-27b-nvfp4. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use beileng/rewrite2-27b-nvfp4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use beileng/rewrite2-27b-nvfp4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="beileng/rewrite2-27b-nvfp4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("beileng/rewrite2-27b-nvfp4") model = AutoModelForCausalLM.from_pretrained("beileng/rewrite2-27b-nvfp4", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use beileng/rewrite2-27b-nvfp4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "beileng/rewrite2-27b-nvfp4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "beileng/rewrite2-27b-nvfp4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/beileng/rewrite2-27b-nvfp4
- SGLang
How to use beileng/rewrite2-27b-nvfp4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "beileng/rewrite2-27b-nvfp4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "beileng/rewrite2-27b-nvfp4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "beileng/rewrite2-27b-nvfp4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "beileng/rewrite2-27b-nvfp4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use beileng/rewrite2-27b-nvfp4 with Docker Model Runner:
docker model run hf.co/beileng/rewrite2-27b-nvfp4
北棱 commited on
rewrite model card: prompts, usage, formats, limits
Browse files125 unmodified lines12612712812913013113213313431 unmodified lines16616716816917017117225 unmodified lines198199200201202203204125 unmodified lines这个模型是按「约 800 汉字原文 → 约 540 汉字压缩改写」的训练分布学的,默认不是等长改写。上下文有 4096 tokens,塞得下 1,500–3,000 字,但模型不会因此覆盖全文:它往往展开开头、压缩后半,长度不够时补写。**默认做法:按自然段/场景切,每段 500–700 汉字,逐段改写,不需要重叠。** 大多数小说段落本身就在这个长度内;按空行、场景转换、对话轮次结束处切即可。每段都完整带「固定提示词 + 本段原文」,改完按顺序拼接。只有在**同一场景或同一段对话不得不从中间切开**、下一段开头离开上一段就接不上时,才用可选的重叠:把上一段最后 1–2 句(约 50–100 字)附在下一段开头,一起改写;拼接时删掉下一段开头重复的部分。能挪到自然段边界时,优先挪切点,不要为了重叠而重叠。### 最小实现31 unmodified linesfinal = "\n\n".join(outputs)```> `rewrite_with_fixed_prompt` 就是「`INSTRUCTION_rewrite.txt` + 该段正文」发一次请求。默认不需要重叠;需要时把上一段最后 1–2 句拼到下一段开头,改写后删掉重复部分。代码只保证不超过 `max_chars`,短段按自然段保留,不要把相邻短段强行凑长。### 切分参考25 unmodified lines| max_tokens | 改写建议 ≤1200;扩写建议 ≤1600;不要设 300–500 的小上限 || 重复惩罚 | **建议 `repetition_penalty=1.08` 起步**;llama.cpp 使用 `--repeat-penalty 1.08` || 原文长度 | **500–800 汉字(约 330–530 tokens)**,另加 81 tokens 固定提示词;长文按 500–700 字切段 || 长文切分 | 按场景/段落切 500–700 字;默认不重叠,同场景中途切开时才带 50–100 字上文 || 输出长度 | 默认压缩改写,约为原文的 0.6–0.8 倍;要等长需显式要求并抽查 |训练时 `max_length=2048` tokens,这是上下文上限,不是最佳工作区间。按训练分布,单次原文 500–800 汉字、输出 500–1,000 字最稳;原文超过 1,000 汉字后,照抄、复读、跑题、压缩和收尾不稳的风险都会上升。模型默认会压缩改写,不做等长保证;需要等长时按「长文怎么切」里的方法显式要求并抽查。125 unmodified lines12612712812913013113231 unmodified lines16416516616716816917025 unmodified lines196197198199200201202125 unmodified lines这个模型是按「约 800 汉字原文 → 约 540 汉字压缩改写」的训练分布学的,默认不是等长改写。上下文有 4096 tokens,塞得下 1,500–3,000 字,但模型不会因此覆盖全文:它往往展开开头、压缩后半,长度不够时补写。**做法:按自然段/场景切,每段 500–700 汉字,逐段改写。** 大多数小说段落本身就在这个长度内;按空行、场景转换、对话轮次结束处切即可。每段都完整带「固定提示词 + 本段原文」,改完按顺序拼接。### 最小实现31 unmodified linesfinal = "\n\n".join(outputs)```> `rewrite_with_fixed_prompt` 就是「`INSTRUCTION_rewrite.txt` + 该段正文」发一次请求。代码只保证不超过 `max_chars`,短段按自然段保留,不要把相邻短段强行凑长。### 切分参考25 unmodified lines| max_tokens | 改写建议 ≤1200;扩写建议 ≤1600;不要设 300–500 的小上限 || 重复惩罚 | **建议 `repetition_penalty=1.08` 起步**;llama.cpp 使用 `--repeat-penalty 1.08` || 原文长度 | **500–800 汉字(约 330–530 tokens)**,另加 81 tokens 固定提示词;长文按 500–700 字切段 || 长文切分 | 按场景/段落切 500–700 字;不要整章一次性输入 || 输出长度 | 默认压缩改写,约为原文的 0.6–0.8 倍;要等长需显式要求并抽查 |训练时 `max_length=2048` tokens,这是上下文上限,不是最佳工作区间。按训练分布,单次原文 500–800 汉字、输出 500–1,000 字最稳;原文超过 1,000 汉字后,照抄、复读、跑题、压缩和收尾不稳的风险都会上升。模型默认会压缩改写,不做等长保证;需要等长时按「长文怎么切」里的方法显式要求并抽查。
README.md+3-5