File size: 2,911 Bytes
13ce734
c9adae0
 
 
 
13ce734
6accb96
be365de
13ce734
c9adae0
13ce734
 
c9adae0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ca9195
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9adae0
 
 
 
 
 
 
 
 
 
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
---
title: CGT-LLM-Beta RAG Chatbot
emoji: 🧬
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
license: mit
---

# CGT-LLM-Beta: Genetic Counseling RAG Chatbot

A Retrieval-Augmented Generation (RAG) chatbot for genetic counseling and cascade genetic testing questions.

## Features

- **Evidence-based answers** from medical literature
- **Multiple education levels**: Middle School, High School, College, and Doctoral
- **Source document citations** with full chunk text
- **Similarity scoring** for transparency
- **Flesch-Kincaid readability scores** for all answers
- **Multiple LLM models** to choose from
- **100+ example questions** for testing

## How to Use

1. **Select a model** from the dropdown (default: Llama-3.2-3B-Instruct)
2. **Choose your education level** for personalized answers
3. **Enter your question** or select from example questions
4. **View the answer** with readability score, sources, and similarity scores

## Education Levels

- **Middle School**: Simplified version for ages 12-14
- **High School**: Simplified version for ages 15-18
- **College**: Professional version for undergraduate level
- **Doctoral**: Advanced version for medical professionals

## Models Available

- Llama-3.2-3B-Instruct
- Mistral-7B-Instruct-v0.2
- Llama-4-Scout-17B-16E-Instruct
- MediPhi-Instruct
- MediPhi
- Phi-4-reasoning

## Setup Instructions

### Required: Add HF_TOKEN Secret

This Space uses the Hugging Face Inference API to generate answers. You **must** add your Hugging Face token as a secret:

1. **Get your Hugging Face token:**
   - Go to: https://huggingface.co/settings/tokens
   - Create a new token with "Read" permissions
   - Copy the token

2. **Add token to Space:**
   - Go to your Space settings: https://huggingface.co/spaces/alrahrooh/cgt-llm-chatbot-v2/settings
   - Click on "Variables and secrets" tab
   - Add a new secret:
     - **Name:** `HF_TOKEN`
     - **Value:** Your Hugging Face token
   - Click "Add secret"
   - Restart the Space (it will restart automatically)

3. **Verify it's working:**
   - Check the Space logs - you should see "Using Hugging Face Inference API"
   - Try asking a question in the interface

**Note:** Some models (like Llama) are gated and require you to:
- Request access at the model's page on Hugging Face
- Accept the model's license
- Use a token that has access to the model

## Important Notes

⚠️ **This chatbot provides informational answers based on medical literature. It is not a substitute for professional medical advice, diagnosis, or treatment. Always consult with qualified healthcare providers for medical decisions.**

## Technical Details

- **Vector Database**: ChromaDB with sentence-transformers embeddings
- **RAG System**: Retrieval-Augmented Generation with semantic search
- **Source Attribution**: Full document tracking with chunk-level citations