Spaces:
Running
Running
update readme and metadata
Browse files- README.md +37 -13
- frontend/src/App.jsx +2 -2
- frontend/src/components/ModelInputBar.jsx +2 -2
README.md
CHANGED
|
@@ -1,19 +1,30 @@
|
|
| 1 |
---
|
| 2 |
-
title: Model Structure
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
|
| 14 |
# Run the app locally
|
|
|
|
| 15 |
|
| 16 |
-
### Frontend
|
| 17 |
|
| 18 |
1. Install dependencies:
|
| 19 |
```
|
|
@@ -24,21 +35,34 @@ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-
|
|
| 24 |
```commandline
|
| 25 |
npm run dev
|
| 26 |
```
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
### Backend
|
| 29 |
|
| 30 |
-
1.
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
4.
|
|
|
|
| 37 |
```commandline
|
| 38 |
python install_gpu_packages.py
|
| 39 |
```
|
| 40 |
|
| 41 |
-
5.
|
|
|
|
| 42 |
```commandline
|
| 43 |
uvicorn app:app --reload --host 0.0.0.0 --port 8000
|
| 44 |
```
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Transformer Model Structure Visualizer
|
| 3 |
+
emoji: 🧩
|
| 4 |
colorFrom: indigo
|
| 5 |
+
colorTo: teal
|
| 6 |
sdk: docker
|
| 7 |
+
app_file: backend/app.py
|
| 8 |
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
short_description: Visualize Transformer architectures by providing a transformer model name without downloading weights.
|
| 11 |
+
tags:
|
| 12 |
+
- transformers
|
| 13 |
+
- visualization
|
| 14 |
+
- attention
|
| 15 |
+
- model-architecture
|
| 16 |
+
- huggingface
|
| 17 |
+
- model-layers
|
| 18 |
+
- model-structure
|
| 19 |
+
- hidden-states
|
| 20 |
|
| 21 |
+
---
|
| 22 |
|
| 23 |
|
| 24 |
# Run the app locally
|
| 25 |
+
This app is developed using React + Fastapi. You can run this app locally with the following steps.
|
| 26 |
|
| 27 |
+
### Run Frontend
|
| 28 |
|
| 29 |
1. Install dependencies:
|
| 30 |
```
|
|
|
|
| 35 |
```commandline
|
| 36 |
npm run dev
|
| 37 |
```
|
| 38 |
+
3. Open the browser and access the service from http://localhost:5173/
|
| 39 |
+
|
| 40 |
|
| 41 |
+
### Run Backend
|
| 42 |
|
| 43 |
+
1. **Activate the virtual environment**
|
| 44 |
|
| 45 |
+
Make sure you have your Python virtual environment set up and activated.
|
| 46 |
|
| 47 |
+
2. **Navigate to the backend directory**
|
| 48 |
+
|
| 49 |
+
```commandline
|
| 50 |
+
cd backend
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
3. **Install dependencies**
|
| 54 |
+
```commandline
|
| 55 |
+
pip install -r requirements.txt
|
| 56 |
+
```
|
| 57 |
|
| 58 |
+
4. **(Optional) Install GPU-related packages**
|
| 59 |
+
If you are running on a GPU-enabled device, you can install additional packages (e.g., for faster inference and support for more models):
|
| 60 |
```commandline
|
| 61 |
python install_gpu_packages.py
|
| 62 |
```
|
| 63 |
|
| 64 |
+
5. **Start the backend server**
|
| 65 |
+
Run the FastAPI app with Uvicorn:
|
| 66 |
```commandline
|
| 67 |
uvicorn app:app --reload --host 0.0.0.0 --port 8000
|
| 68 |
```
|
frontend/src/App.jsx
CHANGED
|
@@ -44,7 +44,7 @@ export default function App() {
|
|
| 44 |
Transformer Model Structure Viewer
|
| 45 |
</h1>
|
| 46 |
<p className="text-center text-slate-500 mb-6">
|
| 47 |
-
Enter a model name (e.g. <code>deepseek-ai/
|
| 48 |
architecture.
|
| 49 |
</p>
|
| 50 |
|
|
@@ -74,7 +74,7 @@ export default function App() {
|
|
| 74 |
|
| 75 |
{/* Footer */}
|
| 76 |
<footer className="mt-8 text-slate-500 text-sm text-center">
|
| 77 |
-
|
| 78 |
</footer>
|
| 79 |
</div>
|
| 80 |
);
|
|
|
|
| 44 |
Transformer Model Structure Viewer
|
| 45 |
</h1>
|
| 46 |
<p className="text-center text-slate-500 mb-6">
|
| 47 |
+
Enter a model name (e.g. <code>deepseek-ai/DeepSeek-V3.1</code>) to view its
|
| 48 |
architecture.
|
| 49 |
</p>
|
| 50 |
|
|
|
|
| 74 |
|
| 75 |
{/* Footer */}
|
| 76 |
<footer className="mt-8 text-slate-500 text-sm text-center">
|
| 77 |
+
This app is currently running on free CPU and thus does not support models that use flash_attn. If you have GPU resources available, consider using a local setup for better performance by following the instructions in the <a href="https://huggingface.co/spaces/maomao88/model_structure_viewer/blob/main/README.md" className="text-sky-600 underline">README</a>.
|
| 78 |
</footer>
|
| 79 |
</div>
|
| 80 |
);
|
frontend/src/components/ModelInputBar.jsx
CHANGED
|
@@ -3,9 +3,9 @@ import React, { useState, useEffect, useRef } from "react";
|
|
| 3 |
export default function ModelInputBar({ loading, fetchModelStructure }) {
|
| 4 |
// Single selection: user can pick one of several fetch options
|
| 5 |
const options = [
|
| 6 |
-
{ label: "Not Sure", value: "none", default: "deepseek-ai/
|
| 7 |
{ label: "Causal Language Models (e.g. GPT, LLaMA, Phi, Mistral)", value: "causal", default: "gpt2"},
|
| 8 |
-
{ label: "Masked Language Models (BERT, RoBERTa, DistilBERT)", value: "masked", default: "
|
| 9 |
{ label: "Sequence Classification (text classification, sentiment analysis)", value: "sequence", default: "distilbert-base-uncased" },
|
| 10 |
{ label: "Token Classification (NER, POS tagging)", value: "token", default: "dbmdz/bert-large-cased-finetuned-conll03-english" },
|
| 11 |
{ label: "Question Answering Models (e.g. BERT QA, RoBERTa QA)", value: "qa", default: "distilbert-base-uncased-distilled-squad" },
|
|
|
|
| 3 |
export default function ModelInputBar({ loading, fetchModelStructure }) {
|
| 4 |
// Single selection: user can pick one of several fetch options
|
| 5 |
const options = [
|
| 6 |
+
{ label: "Not Sure", value: "none", default: "deepseek-ai/DeepSeek-V3.1" },
|
| 7 |
{ label: "Causal Language Models (e.g. GPT, LLaMA, Phi, Mistral)", value: "causal", default: "gpt2"},
|
| 8 |
+
{ label: "Masked Language Models (BERT, RoBERTa, DistilBERT)", value: "masked", default: "distilbert-base-uncased" },
|
| 9 |
{ label: "Sequence Classification (text classification, sentiment analysis)", value: "sequence", default: "distilbert-base-uncased" },
|
| 10 |
{ label: "Token Classification (NER, POS tagging)", value: "token", default: "dbmdz/bert-large-cased-finetuned-conll03-english" },
|
| 11 |
{ label: "Question Answering Models (e.g. BERT QA, RoBERTa QA)", value: "qa", default: "distilbert-base-uncased-distilled-squad" },
|