Instructions to use mymusise/gpt2-medium-chinese with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mymusise/gpt2-medium-chinese with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mymusise/gpt2-medium-chinese")# Load model directly from transformers import AutoTokenizer, TF_AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mymusise/gpt2-medium-chinese") model = TF_AutoModelForCausalLM.from_pretrained("mymusise/gpt2-medium-chinese") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mymusise/gpt2-medium-chinese with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mymusise/gpt2-medium-chinese" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mymusise/gpt2-medium-chinese", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mymusise/gpt2-medium-chinese
- SGLang
How to use mymusise/gpt2-medium-chinese 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 "mymusise/gpt2-medium-chinese" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mymusise/gpt2-medium-chinese", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "mymusise/gpt2-medium-chinese" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mymusise/gpt2-medium-chinese", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mymusise/gpt2-medium-chinese with Docker Model Runner:
docker model run hf.co/mymusise/gpt2-medium-chinese
gpt2-medium-chinese
Overview
- Language model: GPT2-Medium
- Model size: 1.2GiB
- Language: Chinese
- Training data: wiki2019zh_corpus
- Source code: gpt2-quickly
Example
from transformers import BertTokenizer, TFGPT2LMHeadModel
from transformers import TextGenerationPipeline
tokenizer = BertTokenizer.from_pretrained("mymusise/EasternFantasyNoval")
model = TFGPT2LMHeadModel.from_pretrained("mymusise/EasternFantasyNoval")
text_generator = TextGenerationPipeline(model, tokenizer)
print(text_generator("今日", max_length=64, repetition_penalty=1.3, do_sample=True, top_k=10))
print(text_generator("跨越山丘", max_length=64, repetition_penalty=1.3, do_sample=True, top_k=10))
输出
[{'generated_text': '今日 , 他 的 作 品 也 在 各 种 报 刊 发 表 。 201 1 年 , 他 开 设 了 他 的 网 页 版 《 the dear 》 。 此 外 , 他 还 在 各 种 电 视 节 目 中 出 现 过 。 2017 年 1 月 , 他 被 任'}]
[{'generated_text': '跨越山丘 , 其 中 有 三 分 之 二 的 地 区 被 划 入 山 区 。 最 高 峰 是 位 于 山 脚 上 的 大 岩 ( ) 。 其 中 的 山 脚 下 有 一 处 有 名 为 的 河 谷 , 因 其 高 度 在 其 中 , 而 得 名 。'}]
- Downloads last month
- 75