{"id":20904167,"url":"https://github.com/visheshc14/llm-fastapi","last_synced_at":"2026-04-16T03:31:36.126Z","repository":{"id":171310624,"uuid":"647719535","full_name":"visheshc14/LLM-FastAPI","owner":"visheshc14","description":"NimbleBox Apprenticeship ML Engineer Task - 1. This project demonstrates the implementation of a Language Model Server using FastAPI and gRPC. It leverages a large language model to generate coherent text based on user input.","archived":false,"fork":false,"pushed_at":"2023-05-31T12:19:07.000Z","size":45,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-31T21:15:30.944Z","etag":null,"topics":["fastapi","grpc","llm-training","multithreading"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/visheshc14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-05-31T11:33:04.000Z","updated_at":"2023-11-10T08:02:38.000Z","dependencies_parsed_at":"2023-07-11T08:16:45.836Z","dependency_job_id":null,"html_url":"https://github.com/visheshc14/LLM-FastAPI","commit_stats":null,"previous_names":["visheshc14/llm-fastapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/visheshc14/LLM-FastAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visheshc14%2FLLM-FastAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visheshc14%2FLLM-FastAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visheshc14%2FLLM-FastAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visheshc14%2FLLM-FastAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/visheshc14","download_url":"https://codeload.github.com/visheshc14/LLM-FastAPI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/visheshc14%2FLLM-FastAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31870506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"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":["fastapi","grpc","llm-training","multithreading"],"created_at":"2024-11-18T13:16:14.507Z","updated_at":"2026-04-16T03:31:36.026Z","avatar_url":"https://github.com/visheshc14.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LLM-FastAPI\nNimbleBox Apprenticeship ML Engineer Task - 1\nThis project demonstrates the implementation of a Language Model Server using FastAPI and gRPC. It leverages a large language model to generate coherent text based on user input. \n\nGetting Started\nTo set up and run the project, follow the steps below:\n\nInstall the required Python packages by running \n    ```bash\n    pip install -r requirements.txt.\n    ```\n\nTrain the language model using `trainer.py`. Provide the dataset file (`--fp argument`) and other training arguments as needed. The trained model weights will be saved in a specified location.\n\nStart the language model server by running `uvicorn server:app --host 0.0.0.0 --port 8000`. The server will listen on `http://localhost:8000` and accept text generation requests.\n\nUse the provided APIs or client.py to generate text by sending requests to the server. Example curl command: \n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"text\": \"Hello\"}' http://localhost:8000/generate\n```\n\nOptionally, use test.py to stress test the server's performance and evaluate its response time under load.\n\nDefine the Protobuf service and message types in `text_generator.proto`:\n\n```\nsyntax = \"proto3\";\n\npackage textgenerator;\n\nservice TextGenerator {\n  rpc GenerateText(TextRequest) returns (TextResponse) {}\n}\n\nmessage TextRequest {\n  string text = 1;\n}\n\nmessage TextResponse {\n  string generated_text = 1;\n}\n```\n\nGenerate the gRPC code using the protoc compiler, you need to install the protobuf and grpcio-tools packages:\n```bash\npip install protobuf grpcio-tools\n```\n```bash\npython -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. text_generator.proto\n```\n\nAfter running the command, you will see two new files generated in the current directory:\n- `text_generator_pb2.py`: Contains the generated code for the Protobuf messages.\n- `text_generator_pb2_grpc.py`: Contains the generated code for the gRPC service.\n\n\n## Crux: ML Engineer\n\nBonus points:\n- if the filepath can be a GitHub gist (eg. this gist)\n- if everything can be run via single shell file\n- if LLM can give coherent reply\n- a file `test.py` that can:\n  - stress test the server using `multithreading`\n  - provide a CLI for using the model *fast*\n\nUltra bonus points:\n- you use gRPC over HTTP/REST\n- you use something other than python (but not C++, Javascript FFS)\n\n### Train a language model and serve it over a FastAPI.\n\n- create a github repository\n- create a file called `trainer.py` which can be accessed via CLI to train an LLM (protip: take a look at `python-fire`). It should take in following arguments:\n  - `fp` the file to finetune the model on\n  - some training arguments as well (protip: don't use `huggingface` try `karpathy/minGPT`)\n  - the result of this should be the model weights saved in some location\n- create a file called `server.py` that serves the LLM over a HTTP/REST over some APIs (protip: use `pydantic` for models)\n- A `curl` command to call the model and get response\n- an ipython notebook that contains steps to run this\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisheshc14%2Fllm-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvisheshc14%2Fllm-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvisheshc14%2Fllm-fastapi/lists"}