Spaces:
Sleeping
Sleeping
File size: 1,884 Bytes
de0ab6c 668ae63 de0ab6c 668ae63 de0ab6c 668ae63 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | ---
title: Crystal Embedder
emoji: 🔮
colorFrom: purple
colorTo: blue
sdk: docker
pinned: false
license: mit
---
# Crystal-Embedder
Compute **Tri-Fusion physics embeddings** for crystal structures.
## What it does
This service takes a crystal structure in CIF format and returns a 2738-dimensional embedding vector that captures:
| Component | Dimensions | Description |
|-----------|------------|-------------|
| **Orb-v3** | 1792 | Force field features (PyTorch) |
| **l-MM** | 758 | Electronic structure features (TensorFlow/MEGNet) |
| **l-OFM** | 188 | Orbital field matrix features (TensorFlow/MEGNet) |
| **Total** | **2738** | Concatenated, L2-normalized |
## API
### `POST /embed`
Compute embedding for a CIF structure.
**Request:**
```json
{
"cif": "data_Si\n_cell_length_a 5.43..."
}
```
**Response:**
```json
{
"vector": [0.123, -0.456, ...],
"dims": 2738
}
```
### `GET /health`
Health check endpoint.
**Response:**
```json
{
"status": "healthy",
"models_loaded": true,
"vector_dims": 2738
}
```
## Example Usage
```python
import httpx
cif_content = open("structure.cif").read()
response = httpx.post(
"https://hafnium49-crystal-embedder.hf.space/embed",
json={"cif": cif_content},
timeout=60
)
embedding = response.json()["vector"]
print(f"Embedding shape: {len(embedding)}") # 2738
```
## Performance
- **Latency:** ~15 seconds per structure (CPU-only)
- **Memory:** ~8GB peak during inference
- **Cold start:** ~2 minutes (model loading)
## Local Development
```bash
# Build
docker build -t crystal-embedder .
# Run
docker run -p 7860:7860 crystal-embedder
# Test
curl http://localhost:7860/health
```
## Powered By
- [MatterVial](https://github.com/rogeriog/MatterVial) - Physics embeddings
- [pymatgen](https://pymatgen.org/) - Crystal structure parsing
- [FastAPI](https://fastapi.tiangolo.com/) - Web framework
|