Spaces:
Runtime error
Runtime error
Commit ·
3396bcc
1
Parent(s): 035b2bd
Cleanup
Browse filesGuess who's back. Project's almost done idk why I paused working on it
- .github/README.md +72 -39
- Dockerfile +3 -3
- README.md +72 -42
- backend/config.py +2 -4
- backend/ollama.py +2 -2
.github/README.md
CHANGED
|
@@ -1,14 +1,34 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
-
|
| 8 |
-
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
## API Endpoints
|
| 14 |
|
|
@@ -23,70 +43,71 @@ A system for compressing long-form content into clear, structured summaries. Pr
|
|
| 23 |
|
| 24 |
All `/summarize/*` endpoints accept an optional `model` field to override the default.
|
| 25 |
|
|
|
|
|
|
|
| 26 |
## Local Setup
|
| 27 |
|
| 28 |
### Prerequisites
|
| 29 |
|
| 30 |
-
- Python 3.11+
|
| 31 |
-
- Node.js 18+ (or an
|
| 32 |
-
-
|
| 33 |
-
- At least one model pulled
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
```bash
|
| 42 |
ollama pull phi4-mini:latest
|
| 43 |
ollama pull qwen3:4b
|
| 44 |
-
# And any other models you may want
|
| 45 |
```
|
| 46 |
|
| 47 |
-
|
| 48 |
-
You can also just download the fine-tuned versions right away from HuggingFace by running the following script, which downloads the fine-tuned models from my HuggingFace space:
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
```
|
| 53 |
-
-->
|
| 54 |
-
|
| 55 |
-
### Test the Quality of the Fine-Tuning
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
```bash
|
| 60 |
-
# Make sure you have the appropriate libraries installed (see requirements.txt and the instructions for running the backend).
|
| 61 |
python -m scripts.test --model phi4-mini:latest
|
| 62 |
```
|
| 63 |
|
|
|
|
|
|
|
| 64 |
### Start the Backend
|
| 65 |
|
| 66 |
```bash
|
| 67 |
-
# Create a venv or conda environment or whatever else you may want
|
| 68 |
pip install -r ../requirements.txt
|
| 69 |
cd backend
|
| 70 |
uvicorn app:app --reload
|
| 71 |
```
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
|
| 75 |
### Run the Frontend
|
| 76 |
|
| 77 |
```bash
|
| 78 |
cd frontend
|
| 79 |
-
npm install
|
| 80 |
npm run dev
|
| 81 |
```
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
## Data
|
| 86 |
|
| 87 |
<!-- markdownlint-disable MD033 -->
|
| 88 |
|
| 89 |
-
References for datasets
|
| 90 |
|
| 91 |
### MediaSum (Interview Summarization)
|
| 92 |
|
|
@@ -106,12 +127,13 @@ Zhu, C., Liu, Y., Mei, J., & Zeng, M. (2021). *MediaSum: A Large-scale Media Int
|
|
| 106 |
|
| 107 |
</details>
|
| 108 |
|
|
|
|
|
|
|
| 109 |
### DialogSum (Dialogue Summarization)
|
| 110 |
|
| 111 |
Chen, Y., Liu, Y., Chen, L., & Zhang, Y. (2021). *DialogSum: A Real-Life Scenario Dialogue Summarization Dataset*. Findings of ACL-IJCNLP 2021. [https://aclanthology.org/2021.findings-acl.449](https://aclanthology.org/2021.findings-acl.449)
|
| 112 |
|
| 113 |
<details>
|
| 114 |
-
|
| 115 |
<summary>BibTeX</summary>
|
| 116 |
|
| 117 |
```bibtex
|
|
@@ -131,13 +153,16 @@ Chen, Y., Liu, Y., Chen, L., & Zhang, Y. (2021). *DialogSum: A Real-Life Scenari
|
|
| 131 |
|
| 132 |
</details>
|
| 133 |
|
|
|
|
|
|
|
| 134 |
### SQuALITY (Long-Document QA)
|
| 135 |
|
| 136 |
-
|
| 137 |
|
| 138 |
-
Wang, A., Pang, R. Y., Chen, A., Phang, J., & Bowman, S. R. (2022). *SQuALITY: Building a Long-Document Summarization Dataset the Hard Way*. arXiv:2205.11465. [https://arxiv.org/abs/2205.11465](https://arxiv.org/abs/2205.11465)
|
| 139 |
|
| 140 |
-
<details>
|
|
|
|
| 141 |
|
| 142 |
```bibtex
|
| 143 |
@article{wang2022squality,
|
|
@@ -155,13 +180,16 @@ Wang, A., Pang, R. Y., Chen, A., Phang, J., & Bowman, S. R. (2022). *SQuALITY: B
|
|
| 155 |
|
| 156 |
</details>
|
| 157 |
|
|
|
|
|
|
|
| 158 |
### MS MARCO (Concise QA)
|
| 159 |
|
| 160 |
-
|
| 161 |
|
| 162 |
Nguyen, T., Rosenberg, M., Song, X., Gao, J., Tiwary, S., Majumder, R., & Deng, L. (2016). *MS MARCO: A Human Generated Machine Reading Comprehension Dataset*.
|
| 163 |
|
| 164 |
-
<details>
|
|
|
|
| 165 |
|
| 166 |
```bibtex
|
| 167 |
@inproceedings{nguyen2016msmarco,
|
|
@@ -175,13 +203,16 @@ Nguyen, T., Rosenberg, M., Song, X., Gao, J., Tiwary, S., Majumder, R., & Deng,
|
|
| 175 |
|
| 176 |
</details>
|
| 177 |
|
| 178 |
-
|
|
|
|
|
|
|
| 179 |
|
| 180 |
-
|
| 181 |
|
| 182 |
Zhong, M., Yin, D., Yu, T., Zaidi, A., Mutuma, M., Jha, R., Awadallah, A. H., Celikyilmaz, A., Liu, Y., Qiu, X., & Radev, D. (2021). *QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarization*. NAACL 2021. [https://arxiv.org/abs/2104.05938](https://arxiv.org/abs/2104.05938)
|
| 183 |
|
| 184 |
-
<details>
|
|
|
|
| 185 |
|
| 186 |
```bibtex
|
| 187 |
@inproceedings{zhong2021qmsum,
|
|
@@ -194,6 +225,8 @@ Zhong, M., Yin, D., Yu, T., Zaidi, A., Mutuma, M., Jha, R., Awadallah, A. H., Ce
|
|
| 194 |
|
| 195 |
</details>
|
| 196 |
|
|
|
|
|
|
|
| 197 |
## License
|
| 198 |
|
| 199 |
[GPL-3.0](LICENSE.md)
|
|
|
|
| 1 |
+
<h1 align="center">Précis</h1>
|
| 2 |
|
| 3 |
+
<p align="center">
|
| 4 |
+
<img src="https://img.shields.io/badge/python-3.11-blue?style=flat-square&logo=python" alt="Python 3.11">
|
| 5 |
+
<img src="https://img.shields.io/badge/node-18+-green?style=flat-square&logo=nodedotjs" alt="Node 18+">
|
| 6 |
+
<img src="https://img.shields.io/badge/ollama-required-orange?style=flat-square&logo=ollama" alt="Ollama">
|
| 7 |
+
<img src="https://img.shields.io/badge/license-GPL--3.0-brightgreen?style=flat-square" alt="License">
|
| 8 |
+
</p>
|
| 9 |
+
|
| 10 |
+
<p align="center">
|
| 11 |
+
<em>Compress long-form content into clear, structured summaries.</em>
|
| 12 |
+
</p>
|
| 13 |
+
|
| 14 |
+
<p align="center">
|
| 15 |
+
Paste a YouTube link, drop in an article, or upload a text file.<br>
|
| 16 |
+
Précis extracts the key facts into a concise summary using a local LLM via <a href="https://ollama.com">Ollama</a>.
|
| 17 |
+
</p>
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
|
| 21 |
## Features
|
| 22 |
|
| 23 |
+
| Capability | Description |
|
| 24 |
+
|---------------------------|-------------------------------------------------------------------------------|
|
| 25 |
+
| **YouTube summarization** | Paste a URL; transcript is fetched automatically via `youtube-transcript-api` |
|
| 26 |
+
| **Article / transcript** | Paste any text directly |
|
| 27 |
+
| **File upload** | Drag-and-drop `.txt` files |
|
| 28 |
+
| **Streaming** | Summaries stream token-by-token from Ollama via NDJSON |
|
| 29 |
+
| **Model switching** | Choose between available Ollama models from the UI |
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
|
| 33 |
## API Endpoints
|
| 34 |
|
|
|
|
| 43 |
|
| 44 |
All `/summarize/*` endpoints accept an optional `model` field to override the default.
|
| 45 |
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
## Local Setup
|
| 49 |
|
| 50 |
### Prerequisites
|
| 51 |
|
| 52 |
+
- **Python** 3.11+
|
| 53 |
+
- **Node.js** 18+ (or an equivalent alternative)
|
| 54 |
+
- **Ollama** (`ollama serve` to run)
|
| 55 |
+
- At least one model pulled, e.g. `ollama pull phi4-mini:latest`
|
| 56 |
|
| 57 |
+
---
|
| 58 |
|
| 59 |
+
### Run the Fine-Tuning
|
| 60 |
|
| 61 |
+
Scripts live in `scripts/`. The project has been tested primarily with **phi4-mini** (Microsoft) and **Qwen 3-4b** (Alibaba), but you can use whichever model you like.
|
| 62 |
|
| 63 |
```bash
|
| 64 |
ollama pull phi4-mini:latest
|
| 65 |
ollama pull qwen3:4b
|
|
|
|
| 66 |
```
|
| 67 |
|
| 68 |
+
---
|
|
|
|
| 69 |
|
| 70 |
+
### Test Fine-Tuning Quality
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
To evaluate summarization accuracy, run the script below against the `test` split. It uses **BERTScore** (0 to 1.0, higher is better), comparing semantic similarity between generated summaries and references. This captures key facts without penalizing different wording.
|
| 73 |
|
| 74 |
```bash
|
|
|
|
| 75 |
python -m scripts.test --model phi4-mini:latest
|
| 76 |
```
|
| 77 |
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
### Start the Backend
|
| 81 |
|
| 82 |
```bash
|
|
|
|
| 83 |
pip install -r ../requirements.txt
|
| 84 |
cd backend
|
| 85 |
uvicorn app:app --reload
|
| 86 |
```
|
| 87 |
|
| 88 |
+
Served at **`http://localhost:8000`** with interactive docs at `/docs`.
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
|
| 92 |
### Run the Frontend
|
| 93 |
|
| 94 |
```bash
|
| 95 |
cd frontend
|
| 96 |
+
npm install
|
| 97 |
npm run dev
|
| 98 |
```
|
| 99 |
|
| 100 |
+
Served at **`http://localhost:5173`**.
|
| 101 |
+
|
| 102 |
+
The frontend dev server proxies API calls to the backend automatically, so you only need to visit `http://localhost:5173`.
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
|
| 106 |
## Data
|
| 107 |
|
| 108 |
<!-- markdownlint-disable MD033 -->
|
| 109 |
|
| 110 |
+
References for datasets and papers used in this project. Click the arrow to expand BibTeX citations.
|
| 111 |
|
| 112 |
### MediaSum (Interview Summarization)
|
| 113 |
|
|
|
|
| 127 |
|
| 128 |
</details>
|
| 129 |
|
| 130 |
+
---
|
| 131 |
+
|
| 132 |
### DialogSum (Dialogue Summarization)
|
| 133 |
|
| 134 |
Chen, Y., Liu, Y., Chen, L., & Zhang, Y. (2021). *DialogSum: A Real-Life Scenario Dialogue Summarization Dataset*. Findings of ACL-IJCNLP 2021. [https://aclanthology.org/2021.findings-acl.449](https://aclanthology.org/2021.findings-acl.449)
|
| 135 |
|
| 136 |
<details>
|
|
|
|
| 137 |
<summary>BibTeX</summary>
|
| 138 |
|
| 139 |
```bibtex
|
|
|
|
| 153 |
|
| 154 |
</details>
|
| 155 |
|
| 156 |
+
---
|
| 157 |
+
|
| 158 |
### SQuALITY (Long-Document QA)
|
| 159 |
|
| 160 |
+
~6,000 stories from Project Gutenberg with human-written summaries and QA pairs, designed to test long-document understanding.
|
| 161 |
|
| 162 |
+
Wang, A., Pang, R. Y., Chen, A., Phang, J., & Bowman, S. R. (2022). *SQuALITY: Building a Long-Document Summarization Dataset the Hard Way*. arXiv:2205.11465. [https://arxiv.org/abs/2205.11465](https://arxiv.org/abs/2205.11465) | [GitHub](https://github.com/nyu-mll/SQuALITY)
|
| 163 |
|
| 164 |
+
<details>
|
| 165 |
+
<summary>BibTeX</summary>
|
| 166 |
|
| 167 |
```bibtex
|
| 168 |
@article{wang2022squality,
|
|
|
|
| 180 |
|
| 181 |
</details>
|
| 182 |
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
### MS MARCO (Concise QA)
|
| 186 |
|
| 187 |
+
Real user queries from Bing paired with relevant web passages. Useful for concise QA tasks.
|
| 188 |
|
| 189 |
Nguyen, T., Rosenberg, M., Song, X., Gao, J., Tiwary, S., Majumder, R., & Deng, L. (2016). *MS MARCO: A Human Generated Machine Reading Comprehension Dataset*.
|
| 190 |
|
| 191 |
+
<details>
|
| 192 |
+
<summary>BibTeX</summary>
|
| 193 |
|
| 194 |
```bibtex
|
| 195 |
@inproceedings{nguyen2016msmarco,
|
|
|
|
| 203 |
|
| 204 |
</details>
|
| 205 |
|
| 206 |
+
---
|
| 207 |
+
|
| 208 |
+
### QMSum (Query-based Meeting Summarization)
|
| 209 |
|
| 210 |
+
Transcript QA dataset sourced from meetings. [GitHub](https://github.com/Yale-LILY/QMSum)
|
| 211 |
|
| 212 |
Zhong, M., Yin, D., Yu, T., Zaidi, A., Mutuma, M., Jha, R., Awadallah, A. H., Celikyilmaz, A., Liu, Y., Qiu, X., & Radev, D. (2021). *QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarization*. NAACL 2021. [https://arxiv.org/abs/2104.05938](https://arxiv.org/abs/2104.05938)
|
| 213 |
|
| 214 |
+
<details>
|
| 215 |
+
<summary>BibTeX</summary>
|
| 216 |
|
| 217 |
```bibtex
|
| 218 |
@inproceedings{zhong2021qmsum,
|
|
|
|
| 225 |
|
| 226 |
</details>
|
| 227 |
|
| 228 |
+
---
|
| 229 |
+
|
| 230 |
## License
|
| 231 |
|
| 232 |
[GPL-3.0](LICENSE.md)
|
Dockerfile
CHANGED
|
@@ -27,9 +27,9 @@ COPY requirements.txt .
|
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
# Copy frontend
|
| 30 |
-
COPY frontend ./frontend
|
| 31 |
-
WORKDIR /app/frontend
|
| 32 |
-
RUN npm install && npm run build
|
| 33 |
|
| 34 |
# Copy backend
|
| 35 |
WORKDIR /app
|
|
|
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
# Copy frontend
|
| 30 |
+
# COPY frontend ./frontend
|
| 31 |
+
# WORKDIR /app/frontend
|
| 32 |
+
# RUN npm install && npm run build
|
| 33 |
|
| 34 |
# Copy backend
|
| 35 |
WORKDIR /app
|
README.md
CHANGED
|
@@ -9,19 +9,40 @@ python_version: "3.11"
|
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
|
|
|
| 12 |
<!-- markdownlint-disable MD025 -->
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## Features
|
| 19 |
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
## API Endpoints
|
| 27 |
|
|
@@ -36,74 +57,71 @@ A system for compressing long-form content into clear, structured summaries. Pr
|
|
| 36 |
|
| 37 |
All `/summarize/*` endpoints accept an optional `model` field to override the default.
|
| 38 |
|
|
|
|
|
|
|
| 39 |
## Local Setup
|
| 40 |
|
| 41 |
### Prerequisites
|
| 42 |
|
| 43 |
-
- Python 3.11+
|
| 44 |
-
- Node.js 18+ (or an
|
| 45 |
-
-
|
| 46 |
-
- At least one model pulled
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
```bash
|
| 55 |
ollama pull phi4-mini:latest
|
| 56 |
ollama pull qwen3:4b
|
| 57 |
-
# And any other models you may want
|
| 58 |
```
|
| 59 |
|
| 60 |
-
|
| 61 |
-
You can also just download the fine-tuned versions right away from HuggingFace by running the following script, which downloads the fine-tuned models from my HuggingFace space:
|
| 62 |
-
|
| 63 |
-
```bash
|
| 64 |
-
|
| 65 |
-
```
|
| 66 |
-
-->
|
| 67 |
|
| 68 |
-
### Test
|
| 69 |
|
| 70 |
-
|
| 71 |
|
| 72 |
```bash
|
| 73 |
-
# Make sure you have the appropriate libraries installed (see requirements.txt and the instructions for running the backend).
|
| 74 |
python -m scripts.test --model phi4-mini:latest
|
| 75 |
```
|
| 76 |
|
|
|
|
|
|
|
| 77 |
### Start the Backend
|
| 78 |
|
| 79 |
```bash
|
| 80 |
-
# Create a venv or conda environment or whatever else you may want
|
| 81 |
pip install -r ../requirements.txt
|
| 82 |
cd backend
|
| 83 |
uvicorn app:app --reload
|
| 84 |
```
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
| 89 |
|
| 90 |
-
|
| 91 |
|
| 92 |
```bash
|
| 93 |
cd frontend
|
| 94 |
-
npm install
|
| 95 |
npm run dev
|
| 96 |
```
|
| 97 |
|
| 98 |
-
|
|
|
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
|
| 102 |
## Data
|
| 103 |
|
| 104 |
<!-- markdownlint-disable MD033 -->
|
| 105 |
|
| 106 |
-
References for datasets
|
| 107 |
|
| 108 |
### MediaSum (Interview Summarization)
|
| 109 |
|
|
@@ -123,12 +141,13 @@ Zhu, C., Liu, Y., Mei, J., & Zeng, M. (2021). *MediaSum: A Large-scale Media Int
|
|
| 123 |
|
| 124 |
</details>
|
| 125 |
|
|
|
|
|
|
|
| 126 |
### DialogSum (Dialogue Summarization)
|
| 127 |
|
| 128 |
Chen, Y., Liu, Y., Chen, L., & Zhang, Y. (2021). *DialogSum: A Real-Life Scenario Dialogue Summarization Dataset*. Findings of ACL-IJCNLP 2021. [https://aclanthology.org/2021.findings-acl.449](https://aclanthology.org/2021.findings-acl.449)
|
| 129 |
|
| 130 |
<details>
|
| 131 |
-
|
| 132 |
<summary>BibTeX</summary>
|
| 133 |
|
| 134 |
```bibtex
|
|
@@ -148,13 +167,16 @@ Chen, Y., Liu, Y., Chen, L., & Zhang, Y. (2021). *DialogSum: A Real-Life Scenari
|
|
| 148 |
|
| 149 |
</details>
|
| 150 |
|
|
|
|
|
|
|
| 151 |
### SQuALITY (Long-Document QA)
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
Wang, A., Pang, R. Y., Chen, A., Phang, J., & Bowman, S. R. (2022). *SQuALITY: Building a Long-Document Summarization Dataset the Hard Way*. arXiv:2205.11465. [https://arxiv.org/abs/2205.11465](https://arxiv.org/abs/2205.11465)
|
| 156 |
|
| 157 |
-
<details>
|
|
|
|
| 158 |
|
| 159 |
```bibtex
|
| 160 |
@article{wang2022squality,
|
|
@@ -172,13 +194,16 @@ Wang, A., Pang, R. Y., Chen, A., Phang, J., & Bowman, S. R. (2022). *SQuALITY: B
|
|
| 172 |
|
| 173 |
</details>
|
| 174 |
|
|
|
|
|
|
|
| 175 |
### MS MARCO (Concise QA)
|
| 176 |
|
| 177 |
-
|
| 178 |
|
| 179 |
Nguyen, T., Rosenberg, M., Song, X., Gao, J., Tiwary, S., Majumder, R., & Deng, L. (2016). *MS MARCO: A Human Generated Machine Reading Comprehension Dataset*.
|
| 180 |
|
| 181 |
-
<details>
|
|
|
|
| 182 |
|
| 183 |
```bibtex
|
| 184 |
@inproceedings{nguyen2016msmarco,
|
|
@@ -192,13 +217,16 @@ Nguyen, T., Rosenberg, M., Song, X., Gao, J., Tiwary, S., Majumder, R., & Deng,
|
|
| 192 |
|
| 193 |
</details>
|
| 194 |
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
|
| 198 |
|
| 199 |
Zhong, M., Yin, D., Yu, T., Zaidi, A., Mutuma, M., Jha, R., Awadallah, A. H., Celikyilmaz, A., Liu, Y., Qiu, X., & Radev, D. (2021). *QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarization*. NAACL 2021. [https://arxiv.org/abs/2104.05938](https://arxiv.org/abs/2104.05938)
|
| 200 |
|
| 201 |
-
<details>
|
|
|
|
| 202 |
|
| 203 |
```bibtex
|
| 204 |
@inproceedings{zhong2021qmsum,
|
|
@@ -211,6 +239,8 @@ Zhong, M., Yin, D., Yu, T., Zaidi, A., Mutuma, M., Jha, R., Awadallah, A. H., Ce
|
|
| 211 |
|
| 212 |
</details>
|
| 213 |
|
|
|
|
|
|
|
| 214 |
## License
|
| 215 |
|
| 216 |
[GPL-3.0](LICENSE.md)
|
|
|
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
---
|
| 12 |
+
|
| 13 |
<!-- markdownlint-disable MD025 -->
|
| 14 |
|
| 15 |
+
<h1 align="center">Précis</h1>
|
| 16 |
+
|
| 17 |
+
<p align="center">
|
| 18 |
+
<img src="https://img.shields.io/badge/python-3.11-blue?style=flat-square&logo=python" alt="Python 3.11">
|
| 19 |
+
<img src="https://img.shields.io/badge/node-18+-green?style=flat-square&logo=nodedotjs" alt="Node 18+">
|
| 20 |
+
<img src="https://img.shields.io/badge/ollama-required-orange?style=flat-square&logo=ollama" alt="Ollama">
|
| 21 |
+
<img src="https://img.shields.io/badge/license-GPL--3.0-brightgreen?style=flat-square" alt="License">
|
| 22 |
+
</p>
|
| 23 |
+
|
| 24 |
+
<p align="center">
|
| 25 |
+
<em>Compress long-form content into clear, structured summaries.</em>
|
| 26 |
+
</p>
|
| 27 |
|
| 28 |
+
<p align="center">
|
| 29 |
+
Paste a YouTube link, drop in an article, or upload a text file.<br>
|
| 30 |
+
Précis extracts the key facts into a concise summary using a local LLM via <a href="https://ollama.com">Ollama</a>.
|
| 31 |
+
</p>
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
|
| 35 |
## Features
|
| 36 |
|
| 37 |
+
| Capability | Description |
|
| 38 |
+
|---------------------------|-------------------------------------------------------------------------------|
|
| 39 |
+
| **YouTube summarization** | Paste a URL; transcript is fetched automatically via `youtube-transcript-api` |
|
| 40 |
+
| **Article / transcript** | Paste any text directly |
|
| 41 |
+
| **File upload** | Drag-and-drop `.txt` files |
|
| 42 |
+
| **Streaming** | Summaries stream token-by-token from Ollama via NDJSON |
|
| 43 |
+
| **Model switching** | Choose between available Ollama models from the UI |
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
|
| 47 |
## API Endpoints
|
| 48 |
|
|
|
|
| 57 |
|
| 58 |
All `/summarize/*` endpoints accept an optional `model` field to override the default.
|
| 59 |
|
| 60 |
+
---
|
| 61 |
+
|
| 62 |
## Local Setup
|
| 63 |
|
| 64 |
### Prerequisites
|
| 65 |
|
| 66 |
+
- **Python** 3.11+
|
| 67 |
+
- **Node.js** 18+ (or an equivalent alternative)
|
| 68 |
+
- **Ollama** (`ollama serve` to run)
|
| 69 |
+
- At least one model pulled, e.g. `ollama pull phi4-mini:latest`
|
| 70 |
|
| 71 |
+
---
|
| 72 |
|
| 73 |
+
### Run the Fine-Tuning
|
| 74 |
|
| 75 |
+
Scripts live in `scripts/`. The project has been tested primarily with **phi4-mini** (Microsoft) and **Qwen 3-4b** (Alibaba), but you can use whichever model you like.
|
| 76 |
|
| 77 |
```bash
|
| 78 |
ollama pull phi4-mini:latest
|
| 79 |
ollama pull qwen3:4b
|
|
|
|
| 80 |
```
|
| 81 |
|
| 82 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
### Test Fine-Tuning Quality
|
| 85 |
|
| 86 |
+
To evaluate summarization accuracy, run the script below against the `test` split. It uses **BERTScore** (0 to 1.0, higher is better), comparing semantic similarity between generated summaries and references. This captures key facts without penalizing different wording.
|
| 87 |
|
| 88 |
```bash
|
|
|
|
| 89 |
python -m scripts.test --model phi4-mini:latest
|
| 90 |
```
|
| 91 |
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
### Start the Backend
|
| 95 |
|
| 96 |
```bash
|
|
|
|
| 97 |
pip install -r ../requirements.txt
|
| 98 |
cd backend
|
| 99 |
uvicorn app:app --reload
|
| 100 |
```
|
| 101 |
|
| 102 |
+
Served at **`http://localhost:8000`** with interactive docs at `/docs`.
|
| 103 |
|
| 104 |
+
---
|
| 105 |
|
| 106 |
+
### Run the Frontend
|
| 107 |
|
| 108 |
```bash
|
| 109 |
cd frontend
|
| 110 |
+
npm install
|
| 111 |
npm run dev
|
| 112 |
```
|
| 113 |
|
| 114 |
+
Served at **`http://localhost:5173`**.
|
| 115 |
+
|
| 116 |
+
The frontend dev server proxies API calls to the backend automatically, so you only need to visit `http://localhost:5173`.
|
| 117 |
|
| 118 |
+
---
|
| 119 |
|
| 120 |
## Data
|
| 121 |
|
| 122 |
<!-- markdownlint-disable MD033 -->
|
| 123 |
|
| 124 |
+
References for datasets and papers used in this project. Click the arrow to expand BibTeX citations.
|
| 125 |
|
| 126 |
### MediaSum (Interview Summarization)
|
| 127 |
|
|
|
|
| 141 |
|
| 142 |
</details>
|
| 143 |
|
| 144 |
+
---
|
| 145 |
+
|
| 146 |
### DialogSum (Dialogue Summarization)
|
| 147 |
|
| 148 |
Chen, Y., Liu, Y., Chen, L., & Zhang, Y. (2021). *DialogSum: A Real-Life Scenario Dialogue Summarization Dataset*. Findings of ACL-IJCNLP 2021. [https://aclanthology.org/2021.findings-acl.449](https://aclanthology.org/2021.findings-acl.449)
|
| 149 |
|
| 150 |
<details>
|
|
|
|
| 151 |
<summary>BibTeX</summary>
|
| 152 |
|
| 153 |
```bibtex
|
|
|
|
| 167 |
|
| 168 |
</details>
|
| 169 |
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
### SQuALITY (Long-Document QA)
|
| 173 |
|
| 174 |
+
~6,000 stories from Project Gutenberg with human-written summaries and QA pairs, designed to test long-document understanding.
|
| 175 |
|
| 176 |
+
Wang, A., Pang, R. Y., Chen, A., Phang, J., & Bowman, S. R. (2022). *SQuALITY: Building a Long-Document Summarization Dataset the Hard Way*. arXiv:2205.11465. [https://arxiv.org/abs/2205.11465](https://arxiv.org/abs/2205.11465) | [GitHub](https://github.com/nyu-mll/SQuALITY)
|
| 177 |
|
| 178 |
+
<details>
|
| 179 |
+
<summary>BibTeX</summary>
|
| 180 |
|
| 181 |
```bibtex
|
| 182 |
@article{wang2022squality,
|
|
|
|
| 194 |
|
| 195 |
</details>
|
| 196 |
|
| 197 |
+
---
|
| 198 |
+
|
| 199 |
### MS MARCO (Concise QA)
|
| 200 |
|
| 201 |
+
Real user queries from Bing paired with relevant web passages. Useful for concise QA tasks.
|
| 202 |
|
| 203 |
Nguyen, T., Rosenberg, M., Song, X., Gao, J., Tiwary, S., Majumder, R., & Deng, L. (2016). *MS MARCO: A Human Generated Machine Reading Comprehension Dataset*.
|
| 204 |
|
| 205 |
+
<details>
|
| 206 |
+
<summary>BibTeX</summary>
|
| 207 |
|
| 208 |
```bibtex
|
| 209 |
@inproceedings{nguyen2016msmarco,
|
|
|
|
| 217 |
|
| 218 |
</details>
|
| 219 |
|
| 220 |
+
---
|
| 221 |
+
|
| 222 |
+
### QMSum (Query-based Meeting Summarization)
|
| 223 |
|
| 224 |
+
Transcript QA dataset sourced from meetings. [GitHub](https://github.com/Yale-LILY/QMSum)
|
| 225 |
|
| 226 |
Zhong, M., Yin, D., Yu, T., Zaidi, A., Mutuma, M., Jha, R., Awadallah, A. H., Celikyilmaz, A., Liu, Y., Qiu, X., & Radev, D. (2021). *QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarization*. NAACL 2021. [https://arxiv.org/abs/2104.05938](https://arxiv.org/abs/2104.05938)
|
| 227 |
|
| 228 |
+
<details>
|
| 229 |
+
<summary>BibTeX</summary>
|
| 230 |
|
| 231 |
```bibtex
|
| 232 |
@inproceedings{zhong2021qmsum,
|
|
|
|
| 239 |
|
| 240 |
</details>
|
| 241 |
|
| 242 |
+
---
|
| 243 |
+
|
| 244 |
## License
|
| 245 |
|
| 246 |
[GPL-3.0](LICENSE.md)
|
backend/config.py
CHANGED
|
@@ -29,11 +29,9 @@ AVAILABLE_MODELS = _csv_env("AVAILABLE_MODELS", [DEFAULT_MODEL])
|
|
| 29 |
if DEFAULT_MODEL not in AVAILABLE_MODELS:
|
| 30 |
AVAILABLE_MODELS = [DEFAULT_MODEL, *AVAILABLE_MODELS]
|
| 31 |
|
| 32 |
-
ALLOWED_ORIGINS = _csv_env("PRECIS_ALLOWED_ORIGINS", [])
|
| 33 |
-
if not ALLOWED_ORIGINS:
|
| 34 |
-
raise RuntimeError("Missing required environment variable: PRECIS_ALLOWED_ORIGINS")
|
| 35 |
|
| 36 |
-
API_KEY =
|
| 37 |
|
| 38 |
MAX_SUMMARY_TOKENS = int(
|
| 39 |
os.getenv("MAX_SUMMARY_TOKENS", os.getenv("PRECIS_MAX_SUMMARY_TOKENS", "120"))
|
|
|
|
| 29 |
if DEFAULT_MODEL not in AVAILABLE_MODELS:
|
| 30 |
AVAILABLE_MODELS = [DEFAULT_MODEL, *AVAILABLE_MODELS]
|
| 31 |
|
| 32 |
+
ALLOWED_ORIGINS = _csv_env("PRECIS_ALLOWED_ORIGINS", ["http://localhost:5173"])
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
API_KEY = os.getenv("PRECIS_API_KEY") or None
|
| 35 |
|
| 36 |
MAX_SUMMARY_TOKENS = int(
|
| 37 |
os.getenv("MAX_SUMMARY_TOKENS", os.getenv("PRECIS_MAX_SUMMARY_TOKENS", "120"))
|
backend/ollama.py
CHANGED
|
@@ -28,8 +28,8 @@ def build_prompt(title: Optional[str], text: str) -> str:
|
|
| 28 |
return (
|
| 29 |
f"{instructions}\n"
|
| 30 |
"Do not add opinions, commentary, or filler phrases like 'The article discusses' or 'This document provides'.\n"
|
| 31 |
-
"or any similar phrasing, whether the similarity be in meaning or otherwise. Get straight to the point."
|
| 32 |
-
"Output the summary sentence only. The sentence should be no longer than 200
|
| 33 |
f"Article:\n{text}\n\n"
|
| 34 |
"Summary:"
|
| 35 |
)
|
|
|
|
| 28 |
return (
|
| 29 |
f"{instructions}\n"
|
| 30 |
"Do not add opinions, commentary, or filler phrases like 'The article discusses' or 'This document provides'.\n"
|
| 31 |
+
"or any similar phrasing, whether the similarity be in meaning or otherwise. Get straight to the point. "
|
| 32 |
+
"Output the summary sentence only. The sentence should be no longer than 200 characters long. Nothing else should be included.\n\n"
|
| 33 |
f"Article:\n{text}\n\n"
|
| 34 |
"Summary:"
|
| 35 |
)
|