File size: 2,160 Bytes
34187cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Gradio Chatbot
emoji: πŸš€
colorFrom: yellow
colorTo: purple
sdk: gradio
sdk_version: 5.0.1
app_file: app.py
pinned: true
short_description: Chatbot
---


# Gradio Chatbot : HuggingFace SLMs

A modular Gradio-based application for interacting with various small language models through the Hugging Face API.

## Project Structure

```
slm-poc/
β”œβ”€β”€ main.py                 # Main application entry point
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ __init__.py         # Package initialization
β”‚   β”œβ”€β”€ config.py           # Configuration settings and constants
β”‚   β”œβ”€β”€ document_processor.py  # Document handling and processing
β”‚   └── model_handler.py    # Model interaction and response generation
β”œβ”€β”€ Dockerfile              # Docker configuration
β”œβ”€β”€ requirements.txt        # Python dependencies
└── README.md               # Project documentation
```

## Features

- Interactive chat interface with multiple language model options
- Document processing (PDF, DOCX, TXT) for question answering
- Adjustable model parameters (temperature, top_p, max_length)
- Streaming responses for better user experience
- Docker support for easy deployment

## Setup and Running

### Local Development

1. Clone the repository
2. Install dependencies:
   ```
   pip install -r requirements.txt
   ```
3. Create a `.env` file with your HuggingFace API token:
   ```
   HF_TOKEN=hf_your_token_here
   ```
4. Run the application:
   ```
   python main.py
   ```

### Docker Deployment

1. Build the Docker image:
   ```
   docker build -t slm-poc .
   ```
2. Run the container:
   ```
   docker run -p 7860:7860 -e HF_TOKEN=hf_your_token_here slm-poc
   ```

## Usage

1. Access the web interface at http://localhost:7860
2. Enter your HuggingFace API token if not provided via environment variables
3. Select your preferred model and adjust parameters
4. Start chatting with the model
5. Optionally upload documents for document-based Q&A

## Supported Models

T2T Inference models provided by Hugging Face via the Inference API

## License

This project is licensed under the MIT License - see the LICENSE file for details.