Text Generation
Transformers
Safetensors
English
Chinese
qwen3
qwen3-8b
lora
qlora
sft
rag
faiss
dense-retrieval
agent
ppo
rlhf
rule-reward
harness-engineering
um-handbook
question-answering
chatbot
education
tensor-talk
Instructions to use TensorCat/TensorTalk with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TensorCat/TensorTalk with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TensorCat/TensorTalk")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("TensorCat/TensorTalk", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TensorCat/TensorTalk with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TensorCat/TensorTalk" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TensorCat/TensorTalk", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/TensorCat/TensorTalk
- SGLang
How to use TensorCat/TensorTalk 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 "TensorCat/TensorTalk" \ --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": "TensorCat/TensorTalk", "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 "TensorCat/TensorTalk" \ --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": "TensorCat/TensorTalk", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use TensorCat/TensorTalk with Docker Model Runner:
docker model run hf.co/TensorCat/TensorTalk
File size: 10,298 Bytes
36f82a2 8a70417 36f82a2 605c9c4 36f82a2 574c58f 36f82a2 574c58f 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 574c58f 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 605c9c4 8a70417 574c58f 605c9c4 8a70417 605c9c4 8a70417 605c9c4 683bf13 605c9c4 683bf13 605c9c4 683bf13 605c9c4 683bf13 605c9c4 683bf13 605c9c4 574c58f 605c9c4 683bf13 605c9c4 8a70417 605c9c4 8a70417 605c9c4 36f82a2 605c9c4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | ---
license: apache-2.0
language:
- en
- zh
base_model:
- Qwen/Qwen3-8B
pipeline_tag: text-generation
library_name: transformers
tags:
- qwen3
- qwen3-8b
- lora
- qlora
- sft
- rag
- faiss
- dense-retrieval
- agent
- ppo
- rlhf
- rule-reward
- harness-engineering
- um-handbook
- question-answering
- chatbot
- education
- tensor-talk
---
# TensorTalk
**TensorTalk** is a fully deployed Universiti Malaya Faculty of Computer Science and Information Technology handbook QA system built around **Qwen3-8B**, supervised fine-tuning, metadata-aware RAG, an official-source web helper, and a guarded harness for traceable answers.
The project includes the research and training pipeline in this repository, a separately maintained model repository, and a complete Vercel-deployed frontend experience. The live application provides conversation history, handbook and official-web routing, semantic retrieval controls, answer traces, grounding status, and source-aware responses.
## Live Deployment
**Try TensorTalk:** [https://tensor-talk.vercel.app/](https://tensor-talk.vercel.app/)
| Project Component | Link | Role |
| --- | --- | --- |
| Live web application | [tensor-talk.vercel.app](https://tensor-talk.vercel.app/) | Public Vercel deployment for interacting with TensorTalk. |
| Frontend source code | [github.com/nfdlh/tensor-talk](https://github.com/nfdlh/tensor-talk) | Source repository for the deployed web interface. |
| Model repository | [huggingface.co/nfdlh/tensortalk](https://huggingface.co/nfdlh/tensortalk) | Related TensorTalk model repository used by the deployed project. |
| Training and research repository | [TensorCat/TensorTalk/UM_Handbook](https://huggingface.co/TensorCat/TensorTalk/tree/main/UM_Handbook) | SFT, RAG, agent-harness, PPO, datasets, adapters, and evaluation artifacts. |
### Deployment Architecture
```text
User Browser
|
v
Vercel Frontend
https://tensor-talk.vercel.app/
|
+-- Conversation threads and responsive chat interface
+-- Semantic retrieval and routing controls
+-- Evidence, grounding, and tracing views
|
v
TensorTalk Model + RAG / Agent Harness
|
+-- UM handbook knowledge base
+-- Metadata-aware dense retrieval
+-- Official UM / FSKTM web-source helper
+-- Evidence and answer-grounding checks
```
The frontend deployment turns the research notebooks and model artifacts into a complete user-facing application. It exposes the system's intermediate retrieval and validation states instead of presenting TensorTalk as a black-box chatbot.
## Project Demonstration
The following GIF is generated from the complete deployment walkthrough. The original HDR recording was brightness-normalized for readability and accelerated to keep the README demonstration practical.

## What This Project Does
TensorTalk answers handbook-style questions about UM FSKTM academic rules, student guidance, programme details, facilities, dress-code guidance, industrial training, supervision policy, postgraduate requirements, and other faculty handbook topics.
The project compares three stages:
1. **Baseline 1: Closed-book SFT Qwen3-8B**
Fine-tunes Qwen3-8B on handbook question-answer pairs and tests how much the model can answer from parameters alone.
2. **Baseline 2: SFT + metadata-aware RAG + agent harness**
Adds dense retrieval over handbook chunks, metadata reranking, official-source web assistance, and guardrail checks before showing the final answer.
3. **Improved stage: PPO rule-reward post-training + RAG + agent harness**
Experiments with rule-based reward shaping so responses are more grounded, concise, and aligned with the desired handbook-answer style.
## System Design
| Layer | Purpose |
| --- | --- |
| Qwen3-8B base model | General language model foundation. |
| LoRA / QLoRA SFT | Adapts the model to UM FSKTM handbook QA style. |
| Handbook knowledge base | Structured chunks from the undergraduate, postgraduate, and general handbook sources. |
| Dense retrieval + FAISS | Retrieves candidate evidence using `BAAI/bge-base-en-v1.5` embeddings. |
| Metadata-aware reranker | Uses scope, section, subsection, and keywords to reduce wrong-context answers. |
| Official web helper | Searches constrained official UM/FSKTM-related sources when local handbook evidence is not enough. |
| Harness engineering | Runs source guards, fake-URL guards, evidence checks, grounding checks, retry logic, and fallback rules. |
| Vercel frontend | Provides the deployed conversation workspace, history, retrieval controls, and trace views. |
| TensorTalk UI | Shows answers together with traceable RAG, web, and harness evidence panels. |
## Data Assets
The repository includes the core artifacts used to build and evaluate the assistant:
| Artifact | Path | Size / Role |
| --- | --- | --- |
| SFT QA dataset | `UM_Handbook/Dataset/SFT_Dataset/SFT_QA_Training_Ready.jsonl` | 1,000 question-answer rows. |
| SFT metadata | `UM_Handbook/Dataset/SFT_Dataset/SFT_QA_Metadata.jsonl` | 1,000 rows with scope and source metadata. |
| RAG knowledge base | `UM_Handbook/Dataset/RAG/UM_RAG_Knowledge_Base.jsonl` | 521 retrieval chunks. |
| RAG evaluation set | `UM_Handbook/Dataset/RAG/UM_RAG_Evaluation_Dataset.jsonl` | 1,000 retrieval-evaluation rows. |
| Source chunk report | `UM_Handbook/Dataset/Source Chunk Dataset/Source_Chunks_Dataset_report.json` | Chunk distribution and preprocessing notes. |
| Baseline 2 LoRA adapter | `UM_Handbook/outputs/baseline2_rag_harness_agent/lora_adapter/` | PEFT LoRA adapter and tokenizer assets. |
The 521 handbook chunks are split into 58 general, 250 postgraduate, and 213 undergraduate chunks. Low-information cover pages and divider pages are filtered before retrieval.
## Evaluation Snapshot
| Component | Result |
| --- | --- |
| Dataset split | 800 train / 100 validation / 100 test, seed 42. |
| Baseline 2 train loss | 0.2748. |
| Retrieval eval size | 1,000 questions. |
| Hit@1 primary chunk | 82.1%. |
| Hit@3 primary chunk | 95.4%. |
| Hit@3 same knowledge group | 99.1%. |
| Scope match at rank 1 | 99.6%. |
| Plain generation token-F1 | 0.3391 on the sampled generation evaluation. |
| RAG generation token-F1 | 0.8460 on the same sampled evaluation. |
The retrieval results show why the project moved beyond closed-book SFT. The model can speak in the right academic tone after fine-tuning, but RAG and harness checks make the answers more evidence-grounded and easier to audit.
## End-to-End Project Flow
1. Handbook PDFs are converted into structured Markdown.
2. Source chunks and question-answer datasets are built with scope and source metadata.
3. Qwen3-8B is adapted with SFT using LoRA / QLoRA.
4. BGE embeddings and FAISS retrieve handbook evidence, followed by metadata-aware reranking.
5. The agent harness validates sources, rejects unsupported evidence, retries weak retrieval, and checks answer grounding.
6. Rule-reward PPO experiments further shape response behavior.
7. The Vercel frontend exposes the complete workflow through an interactive deployed experience.
## Repository Map
```text
UM_Handbook/
Baseline_1_SFT_QWEN3_UM_Handbook_.ipynb
Baseline_2_RAG_SFT_QWEN3_UM_Handbook_A100_intelligent_harness_agent.ipynb
Improved_Model_PPO_QWEN3_UM_Handbook_RAG_Agent_Harness.ipynb
UM_Handbook_Markdown_Preprocess.py
UM_Source_Chunk_Dataset_Builder.py
UM_SFT_QA_Dataset_Builder_from_Index.py
Dataset/
SFT_Dataset/
RAG/
Source Chunk Dataset/
outputs/
baseline2_rag_harness_agent/
lora_adapter/
retrieval_eval/
generation_eval/
rag_augmented_dataset/
```
## Loading the Baseline 2 Adapter
The Baseline 2 adapter is stored in a subfolder of this repository. A typical PEFT loading flow is:
```python
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_id = "Qwen/Qwen3-8B"
adapter_repo = "TensorCat/TensorTalk"
adapter_subfolder = "UM_Handbook/outputs/baseline2_rag_harness_agent/lora_adapter"
tokenizer = AutoTokenizer.from_pretrained(
adapter_repo,
subfolder=adapter_subfolder,
trust_remote_code=True,
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(
base_model,
adapter_repo,
subfolder=adapter_subfolder,
)
model.eval()
```
For the full TensorTalk behavior shown in the screenshot, use the adapter together with the RAG knowledge base, FAISS retriever, official-source web helper, and harness checks from the notebooks. The model weights alone do not include the live retrieval index or web-agent runtime.
For an immediate end-to-end demonstration, use the [deployed TensorTalk web application](https://tensor-talk.vercel.app/).
## Intended Use
TensorTalk is intended for research, education, and demonstration of:
- handbook question answering for UM FSKTM content;
- RAG-grounded answer generation;
- metadata-aware retrieval and reranking;
- controlled agent behavior over official web sources;
- harness engineering for evidence checks, fake URL detection, retries, and fallback;
- comparing closed-book SFT against retrieval-grounded and reward-shaped systems.
## Out-of-Scope Use
Do not use TensorTalk as an official university policy authority, legal adviser, disciplinary decision system, or fully autonomous student-support system. University policies can change, and final answers should be checked against the latest official UM/FSKTM documents when used for real administrative decisions.
## Limitations
- The strongest behavior comes from the full runtime pipeline, not from the adapter by itself.
- RAG quality depends on the handbook chunks, retrieval metadata, and official-source availability.
- The web helper is intentionally constrained to trusted domains; it is not a general web search assistant.
- PPO in this project is rule-reward post-training, not a large-scale human-feedback RLHF pipeline.
- Some notebook paths reflect the original training environment and may need local path adjustment before rerunning.
## License
This project is released under the Apache 2.0 license.
|