{"id":28814840,"url":"https://github.com/parthapray/text_augmentation_llm_edge","last_synced_at":"2026-05-05T09:32:15.637Z","repository":{"id":299213630,"uuid":"1002366122","full_name":"ParthaPRay/Text_Augmentation_LLM_Edge","owner":"ParthaPRay","description":"This repo shows the coding of text augmentation by using localized LLMs in edge","archived":false,"fork":false,"pushed_at":"2025-06-15T10:48:07.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-15T11:45:01.720Z","etag":null,"topics":["edge","fastapi","llm","ollama","raspberry-pi","textaugment","uvicorn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ParthaPRay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-15T10:12:47.000Z","updated_at":"2025-06-15T10:48:11.000Z","dependencies_parsed_at":"2025-06-15T11:45:03.397Z","dependency_job_id":"f1b5cb22-96dc-420f-be6b-c04a4e9b8a5c","html_url":"https://github.com/ParthaPRay/Text_Augmentation_LLM_Edge","commit_stats":null,"previous_names":["parthapray/text_augmentation_llm_edge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ParthaPRay/Text_Augmentation_LLM_Edge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FText_Augmentation_LLM_Edge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FText_Augmentation_LLM_Edge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FText_Augmentation_LLM_Edge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FText_Augmentation_LLM_Edge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParthaPRay","download_url":"https://codeload.github.com/ParthaPRay/Text_Augmentation_LLM_Edge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParthaPRay%2FText_Augmentation_LLM_Edge/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260586142,"owners_count":23032253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["edge","fastapi","llm","ollama","raspberry-pi","textaugment","uvicorn"],"created_at":"2025-06-18T16:02:53.020Z","updated_at":"2026-05-05T09:32:15.625Z","avatar_url":"https://github.com/ParthaPRay.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TextAugLLMEdge: Localized Text Augmentation on Edge Devices with Quantized LLMs\n\n_Author: Partha Pratim Ray (ppray@cus.ac.in)_\n\n## Overview\n\n**TextAugLLMEdge** is a Python FastAPI application that performs advanced text augmentation using small, quantized large language models (LLMs) served locally on a Raspberry Pi 4B (or similar resource-constrained edge device) via [Ollama](https://ollama.com/).  \nThe framework supports LLMs such as `gemma3:1b`, `granite3.1-moe:1b`, `qwen2:0.5b`, and `smollm2:360m`, and generates a comprehensive CSV with augmentation outputs and diverse linguistic/throughput metrics.\n\n---\n\n## Requirements\n\nCreate a file called `requirements.txt`:\n\n```txt\nfastapi\nuvicorn\nrequests\nnltk\nscikit-learn\n````\n\nThen install dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\nFor BLEU metrics, you must also download NLTK's 'punkt' tokenizer:\n\n```python\nimport nltk\nnltk.download('punkt')\n```\n\n---\n\n## Ollama Setup\n\nEnsure [Ollama](https://ollama.com/) is **installed, models are pulled**, and the Ollama server is running, e.g.:\n\n```bash\nollama serve\nollama pull gemma3:1b\nollama pull granite3.1-moe:1b\nollama pull qwen2:0.5b\nollama pull smollm2:360m\n```\n\n---\n\n## How to Run\n\n### 1. **Start the API Server**\n\nFrom the folder containing `TextAugLLMEdge.py`, run:\n\n```bash\nuvicorn TextAugLLMEdge:app --host 0.0.0.0 --port 8000\n```\n\n### 2. **Trigger the Augmentation Batch**\n\nFrom another terminal (local or remote), trigger a batch run:\n\n```bash\ncurl -X POST http://localhost:8000/run-batch\n```\n\n* The current model is set via the `MODEL` variable in the script (`TextAugLLMEdge.py`). Change this to switch LLMs.\n\n---\n\n## Features\n\n* **Batch Augmentation:** Multiple linguistic augmentation types (paraphrase, synonym, explain simple, summarize, etc.)\n* **Flexible LLM Backend:** Easily switch between locally hosted quantized models (just edit the `MODEL` variable).\n* **Diverse Prompts:** Covers domains like Agriculture, Technology, Medicine, Law, etc.\n* **Comprehensive Metrics:** Output CSV contains:\n\n  * Augmentation metadata (type, prompt, model)\n  * Output text\n  * Ollama timing metrics\n  * Semantic/lexical similarity (Levenshtein, Jaccard, BLEU, Cosine)\n  * Diversity (type-token ratio, char diversity, bigram overlap)\n  * Throughput (tokens/sec), error rates, and more\n\n---\n\n## Output\n\n* Each run produces a timestamped CSV file, e.g. `ollama_aug_results_granite3.1-moe_20250615_154200.csv`.\n* Each row = (prompt, augmentation type, LLM, generated text, metrics).\n\n---\n\n## Code Quickstart\n\n### BLEU Setup (first run):\n\n```python\nimport nltk\nnltk.download('punkt')\n```\n\n### Example Server Command\n\n```bash\nuvicorn TextAugLLMEdge:app --host 0.0.0.0 --port 8000\n```\n\n### Example CURL Trigger\n\n```bash\ncurl -X POST http://localhost:8000/run-batch\n```\n\n---\n\n## Customization\n\n* To **change the LLM model**, set the `MODEL` variable in the script.\n* To add/remove **augmentation types**, edit the `AUGMENT_TYPES` dict.\n* To change **prompts**, edit the `TEST_PROMPTS` list.\n* All output CSVs are saved in the current directory.\n\n\n---\n\n## License\n\nMIT License (or specify your actual license here).\n\n---\n\n## Contact\n\nFor questions or collaborations, contact [ppray@cus.ac.in](mailto:ppray@cus.ac.in).\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparthapray%2Ftext_augmentation_llm_edge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparthapray%2Ftext_augmentation_llm_edge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparthapray%2Ftext_augmentation_llm_edge/lists"}