Files
Typst-Coder-1.5B/README.md
ModelHub XC 111b5d9023 初始化项目,由ModelHub XC社区提供模型
Model: TechxGenus-MS/Typst-Coder-1.5B
Source: Original Platform
2026-06-27 00:33:14 +08:00

61 lines
2.0 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
tags:
- code
base_model:
- 01-ai/Yi-Coder-1.5B
library_name: transformers
pipeline_tag: text-generation
license: apache-2.0
---
# Typst-Coder
<p align="center">
<a href="https://huggingface.co/TechxGenus/Typst-Coder-1.5B">[🤖Models]</a> |
<a href="https://github.com/TechxGenus/Typst-Coder">[🛠Code]</a> |
<a href="https://huggingface.co/datasets/TechxGenus/Typst-Train">[📊Data]</a> |
</p>
<hr>
- [Typst-Coder](#typst-coder)
- [Introduction](#introduction)
- [Usage](#usage)
<hr>
## Introduction
While working with Typst documents, we noticed that AI programming assistants often generate poor results. I understand that these assistants may perform better in languages like Python and JavaScript, which benefit from more extensive datasets and feedback signals from executable code, unlike HTML or Markdown. However, current LLMs even frequently struggle to produce accurate Typst syntax, including models like GPT-4o and Claude-3.5-Sonnet.
Upon further investigation, we found that because Typst is a relatively new language, training data for it is scarce. GitHub's search tool doesn't categorize it as a language for code yet, and The Stack v1/v2 dont include Typst. No open code LLMs currently list it as a supported language, either. To address this, we developed this project aimed at collecting relevant data and training models to improve Typst support in AI programming tools.
## Usage
An example script is shown below:
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("TechxGenus/Typst-Coder-1.5B")
model = AutoModelForCausalLM.from_pretrained(
"TechxGenus/Typst-Coder-1.5B",
torch_dtype=torch.bfloat16,
device_map="auto"
)
messages = [
{"role": "user", "content": "Hi!"},
]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer.encode(prompt, return_tensors="pt")
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=512)
print(tokenizer.decode(outputs[0]))
```