This project leverages a Large Language Model (LLM) to process and generate property data. It is built using Django and focuses on tasks such as rewriting titles and descriptions, generating summaries, ratings, and reviews for properties. Data is initially read from a CSV file and enhanced using the LLM. Later storing datas into PostgreSQl Database.
- Rewriting Titles and Descriptions: Enhances property details using an Ollama model.
- Generating Property Summaries: Summarizes property information in a concise format.
- Creating Ratings and Reviews: Generates synthetic ratings and reviews for properties.
.
├── data_rewrite/ # Main app with settings and configurations
├── hotels/ # App for handling property data models and commands
├── ollama/ # Docker-pulled folder (ignored in repo)
├── hotel_datas.csv # Input CSV with property data
├── manage.py # Django project manager
└── README.md # Project documentation
- Python 3.9+
- Docker
- Django 4.0+
- Ollama LLM Model (pulled via Docker)
git clone https://github.com/samiya1859/LLM_Data_Generating.git
cd LLM_Data_Generatingand create a virtual environment
python3 -m venv env
source env/bin/activate #for Linux
.\env\Scripts\activate #for Windowspip install -r requirements.txtbefore pulling you have to set the docker-compose.yml file as per your database,version information.
docker-compose up -dThe -d flag will run the services in the background.
Check the Logs
docker-compose logs -f ollamaThis will show the logs for the ollama service in real-time
Stop the Services When you're done, stop and remove the containers by running:
docker-compose downpython manage.py makemigrations
python manage.py migrateLoad initial property data from the CSV file:
python manage.py rewrite_titles_description
python manage.py generate_summaries
python manage.py generate_ratings_reviewsRun the custom management command:
python manage.py rewrite_titles_descriptionRun the summary generator:
python manage.py generate_summariesRun the rating and review generator:
python manage.py generate_ratings_reviewsEnsure your hotel_datas.csv file follows this structure:
| id | title | rating | location | latitude | longitude | room_type | price | description |
|---|
This section outlines how to test the functionality of the Ollama model integration, ensuring that the rewritten titles, descriptions, summaries, and generated ratings are accurate and properly populated in your Django models.
python manage.py test
To ensure that your tests cover a substantial portion of the code, you can use a code coverage tool. This section explains how to set up and use coverage to measure the effectiveness of your tests.
First, you need to install the coverage package, which is used to measure the code coverage of your tests. You can install it by running:
pip install coverageOnce coverage is installed, you can run your tests with coverage tracking by using the following command:
coverage run --source='.' manage.py test- --source='.' specifies the directory (your entire project) to monitor for coverage. This tells coverage to track which lines of your code are executed while the tests run.
- manage.py test runs your Django tests.
After running the tests with coverage, generate a human-readable report:
coverage reportThis will display a summary of the code coverage directly in your terminal. It will show you which lines of your code were executed and which were missed.
If you want a more detailed, line-by-line report, you can run:
coverage htmlThis will generate an htmlcov directory with an HTML report. You can open the index.html file in your browser to view the coverage results.
open htmlcov/index.html # For macOS or Linux- The
ollamafolder is ignored in the repository to avoid large file uploads. Pull it via Docker as mentioned above. - Update the project settings if deploying to a production environment.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to open issues or submit pull requests to improve the project!