Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
@@ -1 +1,99 @@
|
|
1 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Materials AI App
|
2 |
+
|
3 |
+
Materials AI App is a production-grade, full-stack web application designed for advanced text mining and data extraction in the materials science and battery research domains. It leverages domain-specific models (MatSciBERT, MaterialBERT, BatteryBERT) along with OpenAI's GPTβ4 for natural language summarization and Q&A. The application uses FastAPI for the backend API and Gradio for an interactive demo interface, and it is deployed on Hugging Face Spaces.
|
4 |
+
|
5 |
+
## Features
|
6 |
+
|
7 |
+
- **Domain-Specific Text Mining:**
|
8 |
+
Extract entities and relations (e.g., material properties, synthesis methods) from scientific literature using specialized BERT models.
|
9 |
+
|
10 |
+
- **Interactive Q&A:**
|
11 |
+
Ask questions related to materials science and battery research and receive context-aware answers.
|
12 |
+
|
13 |
+
- **Summarization:**
|
14 |
+
Generate plain-language summaries of research text with GPTβ4.
|
15 |
+
|
16 |
+
- **User-Friendly Interface:**
|
17 |
+
A Gradio-based demo allows for quick testing and visualization of extracted information.
|
18 |
+
|
19 |
+
- **Scalable & Secure:**
|
20 |
+
Built using FastAPI with containerization (Docker) and CI/CD practices, ensuring robust production deployment on Hugging Face Spaces.
|
21 |
+
|
22 |
+
## Repository Structure
|
23 |
+
|
24 |
+
/materials-ai-app βββ app β βββ init.py β βββ main.py # FastAPI backend server β βββ models.py # Domain model loading and inference functions β βββ openai_integration.py # OpenAI helper functions (e.g., summarization) β βββ utils.py # Utility functions (e.g., text/PDF parsing) βββ gradio_app.py # Gradio demo interface for interactive Q&A and extraction βββ Dockerfile # Docker configuration for containerization βββ requirements.txt # List of Python dependencies βββ README.md # Project documentation (this file)
|
25 |
+
|
26 |
+
bash
|
27 |
+
Copy
|
28 |
+
|
29 |
+
## Installation
|
30 |
+
|
31 |
+
1. **Clone the Repository:**
|
32 |
+
```bash
|
33 |
+
git clone https://huggingface.co/spaces/mgbam/materials-ai-app
|
34 |
+
cd materials-ai-app
|
35 |
+
Set Up a Virtual Environment:
|
36 |
+
|
37 |
+
bash
|
38 |
+
Copy
|
39 |
+
python -m venv venv
|
40 |
+
source venv/bin/activate # On Windows use: venv\Scripts\activate
|
41 |
+
Install Dependencies:
|
42 |
+
|
43 |
+
bash
|
44 |
+
Copy
|
45 |
+
pip install -r requirements.txt
|
46 |
+
Configure Environment Variables: Set the following environment variables (e.g., in a .env file or your shell):
|
47 |
+
|
48 |
+
OPENAI_API_KEY: Your OpenAI API key.
|
49 |
+
|
50 |
+
API_URL: URL of your FastAPI backend (if different from localhost).
|
51 |
+
|
52 |
+
Running Locally
|
53 |
+
Backend API
|
54 |
+
Start the FastAPI server:
|
55 |
+
|
56 |
+
bash
|
57 |
+
Copy
|
58 |
+
uvicorn app.main:app --reload
|
59 |
+
Access the API at http://localhost:8000.
|
60 |
+
|
61 |
+
Gradio Demo
|
62 |
+
In another terminal, run:
|
63 |
+
|
64 |
+
bash
|
65 |
+
Copy
|
66 |
+
python gradio_app.py
|
67 |
+
This launches the interactive Gradio interface for testing extraction and summarization.
|
68 |
+
|
69 |
+
Deployment
|
70 |
+
This repository is configured for deployment on Hugging Face Spaces. Simply push your changes to the repository, and Hugging Face Spaces will build and deploy your app automatically.
|
71 |
+
|
72 |
+
Alternatively, you can use the provided Dockerfile:
|
73 |
+
|
74 |
+
bash
|
75 |
+
Copy
|
76 |
+
docker build -t materials-ai-app .
|
77 |
+
docker run -p 8000:8000 materials-ai-app
|
78 |
+
Contributing
|
79 |
+
Contributions, issues, and feature requests are welcome! Please check the issues page for more details.
|
80 |
+
|
81 |
+
References
|
82 |
+
MatSciBERT on Hugging Face
|
83 |
+
|
84 |
+
Hugging Face Spaces Documentation
|
85 |
+
|
86 |
+
OpenAI API Documentation
|
87 |
+
|
88 |
+
License
|
89 |
+
This project is licensed under the MIT License.
|
90 |
+
|
91 |
+
Contact
|
92 |
+
For any questions or feedback, please reach out to [[email protected]].
|
93 |
+
|
94 |
+
yaml
|
95 |
+
Copy
|
96 |
+
|
97 |
+
---
|
98 |
+
|
99 |
+
You can adjust this template to suit your project's specifics and include any additional sections that might be relevant.
|