This project is a web application built using Django and React for regex pattern matching and replacement in CSV files. It integrates a Large Language Model (LLM) from Meta-Llama-3-8B-Instruct to convert natural language descriptions into regex patterns. A brief demonstration can be found here.
-
Clone the repository:
git clone https://github.com/DoDucNhan/regex_pattern_web.git cd regex_pattern_web -
Backend Setup (Django):
- Ensure Python 3.x and pip are installed.
- Install required Python packages:
pip install -r requirements.txt
- Set up Django environment variables and configuration.
-
Frontend Setup (React):
- Navigate to the
frontenddirectory:
cd regex_frontend- Install dependencies using npm:
npm install axios react-bootstrap bootstrap
- Navigate to the
-
Hugging Face API Token Setup:
- Obtain an API token from Hugging Face following their documentation. (Remember to accept meta terms to be granted access to their models)
- Replace the token in
settings.py:
# regex_app/settings.py HUGGINGFACE_API_KEY = os.getenv('HUGGINGFACE_API_KEY', 'YOUR_KEY')
NOTE: On your first run, it will take time to download the checkpoint for the LLAMA 3 model.
-
Running the Development Servers:
- Navigate to the
regex_appdirectory.
cd regex_app- Start the Django backend server:
python manage.py runserver
- Start the React frontend server (in another terminal window):
cd regex_frontend npm start - Navigate to the
-
Using the Application:
- Access the application in your web browser at
http://localhost:3000. - Upload a CSV or Excel file and describe the pattern you want to match in natural language.
- The application will convert your description into a regex pattern using Meta-Llama-3-8B-Instruct.
- Download the processed CSV file.
- Access the application in your web browser at
- Meta-Llama-3-8B-Instruct for providing the LLM capabilities.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.