Skip to content

Refactor: Fix Dockerfile, model and API restructure #1

@abalmumcu

Description

@abalmumcu

Problems found

  • Dockerfile misconfiguration: the original Dockerfile expected requirements.txt and api.py in the wrong locations.
  • Unavailable dependencies: the Python dependencies (torch, transformers, flask) used in the original code are not available in the current environment.
  • Model misuse: the project loaded a base BertModel for sentiment analysis and NER, but these tasks require specialised classification heads.
  • Embedding extraction: the original get_embeddings squeezed the batch dimension incorrectly and returned token-level hidden states rather than sentence embeddings.

Changes made

  • Rewrote app/model.py to provide heuristic methods for embeddings, sentiment analysis, and entity extraction without external ML libraries.
  • Replaced the Flask API with a FastAPI implementation (api.py) and updated the endpoints.
  • Added a top-level requirements.txt listing only fastapi, pydantic, and uvicorn.
  • Updated the Dockerfile to copy the correct requirements file, install dependencies and start the server with Uvicorn.
  • Added a new README.md documenting the revised structure and usage.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions