Spaces:
Running
Running
Patryk Ptasiński
commited on
Commit
·
3a1e953
1
Parent(s):
65ff348
Add CLAUDE.md with repository guidance for Claude Code
Browse files
CLAUDE.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CLAUDE.md
|
| 2 |
+
|
| 3 |
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
| 4 |
+
|
| 5 |
+
## Project Overview
|
| 6 |
+
|
| 7 |
+
This is a Hugging Face Spaces application that provides text embeddings using the Nomic AI model (nomic-embed-text-v1.5). It runs on CPU and provides both a web interface and API endpoints for generating text embeddings.
|
| 8 |
+
|
| 9 |
+
## Key Commands
|
| 10 |
+
|
| 11 |
+
### Local Development
|
| 12 |
+
```bash
|
| 13 |
+
# Install dependencies
|
| 14 |
+
pip install -r requirements.txt
|
| 15 |
+
|
| 16 |
+
# Run the application locally
|
| 17 |
+
python app.py
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
### Git Operations
|
| 21 |
+
```bash
|
| 22 |
+
# Push to Hugging Face Spaces (requires authentication)
|
| 23 |
+
git push origin main
|
| 24 |
+
|
| 25 |
+
# Note: May need to authenticate with:
|
| 26 |
+
huggingface-cli login
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Architecture
|
| 30 |
+
|
| 31 |
+
The application consists of a single `app.py` file with:
|
| 32 |
+
- **Model Initialization**: SentenceTransformer with `device='cpu'` (line 6)
|
| 33 |
+
- **Embedding Function**: Simple wrapper that calls model.encode() (lines 9-10)
|
| 34 |
+
- **Gradio Interface**: UI components and API endpoint configuration (lines 13-81)
|
| 35 |
+
- **API Endpoint**: Named "predict" for programmatic access (line 27)
|
| 36 |
+
|
| 37 |
+
## Important Configuration Details
|
| 38 |
+
|
| 39 |
+
- **No Queue**: The app launches without `.queue()` to allow direct API calls
|
| 40 |
+
- **CPU Mode**: Explicitly set to CPU to avoid GPU requirements
|
| 41 |
+
- **Trust Remote Code**: Model uses `trust_remote_code=True` for custom Nomic model code
|
| 42 |
+
- **API Structure**: Uses `fn_index: 0` for the predict endpoint
|
| 43 |
+
|
| 44 |
+
## API Usage
|
| 45 |
+
|
| 46 |
+
The `/api/predict` endpoint expects:
|
| 47 |
+
```json
|
| 48 |
+
{
|
| 49 |
+
"fn_index": 0,
|
| 50 |
+
"data": ["text to embed"]
|
| 51 |
+
}
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
Returns embedding array in response.data field.
|
| 55 |
+
|
| 56 |
+
## Deployment Notes
|
| 57 |
+
|
| 58 |
+
- Deployed on Hugging Face Spaces at https://huggingface.co/spaces/ipepe/nomic-embeddings
|
| 59 |
+
- Runs on port 7860
|
| 60 |
+
- Uses Gradio 4.36.1 (newer versions available)
|
| 61 |
+
- PyTorch configured for CPU-only via `--extra-index-url` in requirements.txt
|