Downloads · 30 days
14
36% of all-time downloads
geoffmunn/Qwen3Guard-StarTrek-Classification-4B
Qwen3Guard-StarTrek-Classification-4B is a text classification model from geoffmunn. Use it when you need a label for a piece of text. It is set up for peft.
This is a fine-tuned version of Qwen3-4B using LoRA (Low-Rank Adaptation) to classify whether user-provided text is related to Star Trek or not. The model acts as a domain-specific content classifier, returning one of…
Downloads · 30 days
14
36% of all-time downloads
All-time downloads
39
Public
Repo size
1.6 GB
Likes
0
Public
Click a slice to open those files.
.pt529 MB · 54%
From the Hugging Face model README
This is a fine-tuned version of Qwen3-4B using LoRA (Low-Rank Adaptation) to classify whether user-provided text is related to Star Trek or not. The model acts as a domain-specific content classifier, returning one of two labels: "related" or "not_related". It was developed as part of the Qwen3Guard demonstration project to showcase how large language models can be adapted for custom classification tasks.
This model is a binary sequence classifier fine-tuned on a synthetic dataset of Star Trek-related questions and general non-Star-Trek text. Built atop the Qwen3-4B foundation model, it uses parameter-efficient fine-tuning via LoRA to adapt the model for topic detection in conversational or input text. It is designed for use in moderation systems where filtering based on pop culture topics like Star Trek is desired.
star_trek_chat.html in the repository; requires local API serverThe model can directly classify whether a given piece of text is related to Star Trek. Example applications include:
Input: A string of text
Output: One of two labels — "related" or "not_related"
This model can be integrated into larger systems such as:
This model should not be used for:
It may produce inaccurate classifications when presented with ambiguous references, parody content, or highly technical scientific discussions unrelated to Star Trek lore.
The training data consists entirely of synthetically generated questions about Star Trek, which introduces several limitations:
Additionally, because the dataset was auto-generated using prompts, there may be inconsistencies in labeling or artificial phrasing patterns.
Users should validate performance on real-world data before deployment. For production use, consider augmenting the dataset with human-labeled examples and testing across diverse inputs. Always pair this model with broader safeguards if used in public-facing applications.
You can load and run inference using Hugging Face Transformers:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_id = "geoffmunn/Qwen3Guard-StarTrek-Classification-4B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
input_text = "What is the warp core made of in Star Trek?"
inputs = tokenizer(input_text, return_tensors="pt", truncation=True, max_length=512)
outputs = model(**inputs)
predicted_class_id = outputs.logits.argmax().item()
label = model.config.id2label[predicted_class_id]
print(f"Label: {label}")
Ensure you have the required libraries installed:
pip install transformers torch peft
The model was trained on a synthetic JSONL dataset containing 2,500 labeled examples of Star Trek-related questions marked as "related", and an equal number of randomly sampled general knowledge questions labeled "not_related". The dataset was generated using the script generate_star_trek_questions.py from the repository.
Dataset format:
{"input": "What planet is Spock from?", "label": "related"}
{"input": "Who wrote 'Pride and Prejudice'?", "label": "not_related"}
Place your dataset at: finetuning/star_trek/star_trek_guard_dataset.jsonl
Text inputs were tokenized using the Qwen3 tokenizer with a maximum sequence length of 512 tokens. Inputs longer than this were truncated. Labels were mapped via:
label2id = {"not_related": 0, "related": 1}
id2label = {0: "not_related", 1: "related"}
A 10% holdout test set (~500 samples) was used for evaluation, split from the full dataset during training.
Evaluation focused on accuracy across:
During final evaluation, the model achieved:
The model performs well on its intended task within the scope of the training distribution but may degrade on edge cases or metaphorical references.
GPU: NVIDIA A100 / RTX 3090 / L40S or equivalent RAM: ≥ 32 GB system memory recommended
While no formal paper exists, please cite the GitHub repository if used academically.
BibTeX:
@software{munn_qwen3guard_2025,
author = {Munn, Geoff},
title = {Qwen3Guard: Demonstration of Qwen3Guard Models for Content Classification},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
url = {https://github.com/geoffmunn/Qwen3Guard}
}
Munn, G. (2025). Qwen3Guard: Demonstration of Qwen3Guard Models for Content Classification [Software]. GitHub. https://github.com/geoffmunn/Qwen3Guard
For more details, including API server setup and web demos, visit: 👉 https://github.com/geoffmunn/Qwen3Guard
Includes:
Geoff Munn – Developer and maintainer
For questions or feedback, contact the author via GitHub: @geoffmunn