File size: 2,014 Bytes
b09fd17
70ca8e2
 
 
 
 
 
 
b09fd17
70ca8e2
b09fd17
 
70ca8e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: AI Text Assistant
emoji: πŸ€–
colorFrom: purple
colorTo: blue
sdk: gradio
sdk_version: 4.0.0
app_file: app.py
pinned: false
license: mit
---

# AI Text Assistant

An interactive web application for text generation, summarization, and next-word prediction using transformer models.

## Features

- **Text Generation**: Generate creative text continuations using Qwen2.5-0.5B-Instruct model
- **Text Summarization**: Summarize long texts using BART-large-CNN model
- **Next Word Prediction**: Get top 10 predictions for the next word with probability scores

## Models Used

- **Text Generation**: [Qwen/Qwen2.5-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct)
- **Summarization**: [facebook/bart-large-cnn](https://huggingface.co/facebook/bart-large-cnn)

## Project Structure

```
LocalInference/
β”œβ”€β”€ app.py              # Main FastAPI application
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── style.css  # UI styles
β”‚   └── js/
β”‚       └── app.js     # Client-side JavaScript
└── templates/
    └── index.html     # Main HTML interface
```

## Local Setup

1. **Clone the repository:**
   ```bash
   git clone <repository-url>
   cd LocalInference
   ```

2. **Install dependencies:**
   ```bash
   pip install -r requirements.txt
   ```

3. **Run the application:**
   ```bash
   python app.py
   ```
   
   The application will be accessible at `http://localhost:7860`

## Usage

1. Open the application in your web browser
2. Choose between "Text Generation" or "Text Summarization" mode
3. Enter your text in the input field
4. Adjust max tokens and sampling options as needed
5. Click "Process" to generate results
6. Use "Get Next Word Predictions" to see likely next words

## API Endpoints

- `GET /` - Web interface
- `POST /generate` - Generate or summarize text
- `POST /predict_next` - Get next word predictions

## License

This project is licensed under the MIT License.