{"id":23732446,"url":"https://github.com/willwade/ppm-api","last_synced_at":"2026-07-02T21:33:34.137Z","repository":{"id":269934612,"uuid":"908897109","full_name":"willwade/PPM-API","owner":"willwade","description":"A js ppm api  - word, character or sentence level predictor for any language","archived":false,"fork":false,"pushed_at":"2024-12-28T20:36:21.000Z","size":192,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T06:27:48.715Z","etag":null,"topics":["api","js","language-model","ppm","prediction"],"latest_commit_sha":null,"homepage":"https://ppmpredictor.openassistive.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/willwade.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":"2024-12-27T08:32:41.000Z","updated_at":"2024-12-28T20:36:24.000Z","dependencies_parsed_at":"2025-05-24T00:11:34.855Z","dependency_job_id":"96ebb497-ba86-4333-bc77-39aaa07d84c4","html_url":"https://github.com/willwade/PPM-API","commit_stats":null,"previous_names":["willwade/ppm-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/willwade/PPM-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2FPPM-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2FPPM-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2FPPM-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2FPPM-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willwade","download_url":"https://codeload.github.com/willwade/PPM-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willwade%2FPPM-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35064249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","js","language-model","ppm","prediction"],"created_at":"2024-12-31T04:17:54.099Z","updated_at":"2026-07-02T21:33:34.129Z","avatar_url":"https://github.com/willwade.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PPM Prediction API\n\nA text prediction API using Prediction by Partial Matching (PPM). Train on any text to create personalized predictions, or use the default English training text.\n\n## Features\n- Train on any text of your choice\n- Session-based models for individual customization\n- Predict at letter, word, or sentence level\n- Falls back to default English training if no custom training provided\n\n## Setup\n\n### Prerequisites\n- Node.js (\u003e=20.0.0)\n- npm (\u003e=9.0.0)\n\n### Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/willwade/PPM-API.git\n   cd PPM-API\n   ```\n\n2. Install dependencies:\n   ```bash\n   npm install\n   ```\n\n3. (Optional) Install Python dependencies for generating training text:\n   ```bash\n   pip install datasets\n   ```\n\n### Usage\n\n#### Start the API\nRun the following command to start the API:\n```bash\nnpm start\n```\n\nThe API will be available at `http://localhost:8080`.\n\n\n## API Documentation\n\nOnce running, view the full API documentation at:\n```\nhttp://localhost:8080/api-docs\n```\n\n### Quick Start Guide\n\n1. **Train a Model** (Optional)\n\n```bash\ncurl -X POST http://localhost:8080/train \\\n-H \"Content-Type: application/json\" \\\n-d '{\n\"url\": \"https://www.gutenberg.org/cache/epub/19778/pg19778.txt\",\n\"maxOrder\": 5\n}'\n```\n\nResponse:\n\n```json\n{\n\"success\": true,\n\"sessionId\": \"550e8400-e29b-41d4-a716-446655440000\",\n\"message\": \"Training complete\",\n\"trainingTimeMs\": 1234,\n\"vocabularySizes\": {\n\"letter\": 52,\n\"word\": 2000,\n\"sentence\": 500\n}\n}\n```\n\n2. **Make Predictions**\n\n```bash\ncurl -X POST http://localhost:8080/predict \\\n-H \"Content-Type: application/json\" \\\n-H \"x-session-id: 550e8400-e29b-41d4-a716-446655440000\" \\\n-d '{\n\"input\": \"The quick brown\",\n\"level\": \"word\",\n\"numPredictions\": 5\n}'\n```\n\nResponse:\n\n```json\njson\n{\n\"input\": \"The quick brown\",\n\"level\": \"word\",\n\"predictions\": [\n{\n\"symbol\": \"fox\",\n\"probability\": 0.4,\n\"logProbability\": -0.916\n},\n// ... more predictions\n],\n\"contextOrder\": 3,\n\"perplexity\": 2.5\n}\n```\n\n### Training Options\n\nYou can train the model in two ways:\n\n1. **Using a URL**:\n\n```json\n{\n\"url\": \"https://www.gutenberg.org/cache/epub/19778/pg19778.txt\",\n\"maxOrder\": 5\n}\n```\n\n2. **Using Direct Text**:\n\n```json\n{\n\"text\": \"Your training text here\",\n\"maxOrder\": 5\n}\n```\n\nNote: Provide either `url` OR `text`, but not both.\n\n### Prediction Levels\n\nThe API supports three prediction levels:\n- `letter`: Character-by-character prediction\n- `word`: Word-by-word prediction\n- `sentence`: Full sentence prediction\n\n### Session Management\n\n1. When you train a model, you receive a `sessionId`\n2. Use this `sessionId` in the `x-session-id` header for subsequent predictions\n3. If no `sessionId` is provided, the API uses default English training text\n\n## Deployment\n\n### DigitalOcean App Platform\n1. Fork this repository\n2. Connect your DigitalOcean account\n3. Create a new App from your forked repository\n4. Deploy using Node.js settings:\n   - Environment: Node.js\n   - Build Command: `npm install`\n   - Run Command: `npm start`\n\n\n### Generate Training Text\n\nTo generate training text from datasets (Alice in Wonderland, AAC-like phrases, filtered dialogue):\n\n1. Run the Python script:\n   ```bash\n   python generate_training_text.py\n   ```\n2. The generated text will be saved to `training_text.txt`.\n\n\n### Issues\n\nIf you encounter any issues, please [open an issue](https://github.com/willwade/PPM-API/issues).\n\n### License\n\nThis project is licensed under the GPL v 3.0 License - see the [LICENSE](LICENSE) file for details.\n\n\n### Acknowledgements\n\nPPM JS Was developed by Google Research - https://github.com/google-research/google-research/tree/master/jslm\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillwade%2Fppm-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillwade%2Fppm-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillwade%2Fppm-api/lists"}