Spaces:
Sleeping
Sleeping
Jac-Zac commited on
Commit ·
76d718f
1
Parent(s): a89a7f1
Explained local setup
Browse files- README.md +20 -0
- pyproject.toml +4 -9
- utils/chat.py +4 -3
- uv.lock +29 -13
README.md
CHANGED
|
@@ -45,6 +45,26 @@ uv sync
|
|
| 45 |
cp .env.example .env
|
| 46 |
```
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
## Quickstart
|
| 49 |
|
| 50 |
```bash
|
|
|
|
| 45 |
cp .env.example .env
|
| 46 |
```
|
| 47 |
|
| 48 |
+
## Local Setup Note
|
| 49 |
+
|
| 50 |
+
For now, `persona-data` and `persona-vectors` need to be checked out in the parent directory of `persona-ui`.
|
| 51 |
+
|
| 52 |
+
Example:
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
git clone <persona-data-url> ../persona-data
|
| 56 |
+
git clone <persona-vectors-url> ../persona-vectors
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
Expected layout:
|
| 60 |
+
|
| 61 |
+
```text
|
| 62 |
+
parent/
|
| 63 |
+
├── persona-ui
|
| 64 |
+
├── persona-data
|
| 65 |
+
└── persona-vectors
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
## Quickstart
|
| 69 |
|
| 70 |
```bash
|
pyproject.toml
CHANGED
|
@@ -7,21 +7,16 @@ requires-python = ">=3.10"
|
|
| 7 |
dependencies = [
|
| 8 |
"persona-vectors",
|
| 9 |
"persona-data",
|
| 10 |
-
"nnterp>=1.3.0",
|
| 11 |
"streamlit>=1.44.0",
|
| 12 |
"plotly>=6.6.0",
|
| 13 |
-
"kaleido>=1.0.0",
|
| 14 |
"python-dotenv>=1.2.2",
|
| 15 |
-
"torch>=2.10.0",
|
| 16 |
-
"transformers>=5.2.0",
|
| 17 |
]
|
| 18 |
|
| 19 |
[tool.uv.sources]
|
| 20 |
-
|
| 21 |
-
persona-
|
| 22 |
-
persona-
|
| 23 |
-
# persona-
|
| 24 |
-
# persona-data = { path = "../persona-data", editable = true }
|
| 25 |
|
| 26 |
# [build-system]
|
| 27 |
# requires = ["uv_build>=0.11.3,<0.12"]
|
|
|
|
| 7 |
dependencies = [
|
| 8 |
"persona-vectors",
|
| 9 |
"persona-data",
|
|
|
|
| 10 |
"streamlit>=1.44.0",
|
| 11 |
"plotly>=6.6.0",
|
|
|
|
| 12 |
"python-dotenv>=1.2.2",
|
|
|
|
|
|
|
| 13 |
]
|
| 14 |
|
| 15 |
[tool.uv.sources]
|
| 16 |
+
persona-vectors = { path = "../persona-vectors", editable = true }
|
| 17 |
+
persona-data = { path = "../persona-data", editable = true }
|
| 18 |
+
# persona-vectors = { git = "ssh://git@github.com/implicit-personalization/persona-vectors.git" } # use for release
|
| 19 |
+
# persona-data = { git = "ssh://git@github.com/implicit-personalization/persona-data.git" } # use for release
|
|
|
|
| 20 |
|
| 21 |
# [build-system]
|
| 22 |
# requires = ["uv_build>=0.11.3,<0.12"]
|
utils/chat.py
CHANGED
|
@@ -10,6 +10,7 @@ logger = logging.getLogger(__name__)
|
|
| 10 |
|
| 11 |
from persona_data.synth_persona import PersonaData
|
| 12 |
from persona_data.prompts import (
|
|
|
|
| 13 |
format_biography_prompt,
|
| 14 |
format_templated_prompt,
|
| 15 |
normalize_messages,
|
|
@@ -17,8 +18,6 @@ from persona_data.prompts import (
|
|
| 17 |
|
| 18 |
SystemPromptMode = Literal["empty", "templated", "biography", "custom"]
|
| 19 |
|
| 20 |
-
_CUSTOM_PROMPT_DEFAULT = "You are a helpful assistant."
|
| 21 |
-
|
| 22 |
|
| 23 |
@dataclass
|
| 24 |
class ChatReply:
|
|
@@ -45,12 +44,14 @@ def resolve_system_prompt(
|
|
| 45 |
if persona is None:
|
| 46 |
return ""
|
| 47 |
|
|
|
|
|
|
|
| 48 |
if mode == "templated":
|
| 49 |
return format_templated_prompt(persona.templated_prompt)
|
| 50 |
if mode == "biography":
|
| 51 |
return format_biography_prompt(persona.biography_md)
|
| 52 |
if mode == "custom":
|
| 53 |
-
return
|
| 54 |
return ""
|
| 55 |
|
| 56 |
|
|
|
|
| 10 |
|
| 11 |
from persona_data.synth_persona import PersonaData
|
| 12 |
from persona_data.prompts import (
|
| 13 |
+
format_empty_persona_prompt,
|
| 14 |
format_biography_prompt,
|
| 15 |
format_templated_prompt,
|
| 16 |
normalize_messages,
|
|
|
|
| 18 |
|
| 19 |
SystemPromptMode = Literal["empty", "templated", "biography", "custom"]
|
| 20 |
|
|
|
|
|
|
|
| 21 |
|
| 22 |
@dataclass
|
| 23 |
class ChatReply:
|
|
|
|
| 44 |
if persona is None:
|
| 45 |
return ""
|
| 46 |
|
| 47 |
+
if mode == "empty":
|
| 48 |
+
return ""
|
| 49 |
if mode == "templated":
|
| 50 |
return format_templated_prompt(persona.templated_prompt)
|
| 51 |
if mode == "biography":
|
| 52 |
return format_biography_prompt(persona.biography_md)
|
| 53 |
if mode == "custom":
|
| 54 |
+
return format_empty_persona_prompt()
|
| 55 |
return ""
|
| 56 |
|
| 57 |
|
uv.lock
CHANGED
|
@@ -1561,7 +1561,7 @@ wheels = [
|
|
| 1561 |
[[package]]
|
| 1562 |
name = "persona-data"
|
| 1563 |
version = "0.1.0"
|
| 1564 |
-
source = {
|
| 1565 |
dependencies = [
|
| 1566 |
{ name = "huggingface-hub" },
|
| 1567 |
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
|
@@ -1570,41 +1570,40 @@ dependencies = [
|
|
| 1570 |
{ name = "torch" },
|
| 1571 |
]
|
| 1572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1573 |
[[package]]
|
| 1574 |
name = "persona-ui"
|
| 1575 |
version = "0.1.0"
|
| 1576 |
source = { virtual = "." }
|
| 1577 |
dependencies = [
|
| 1578 |
-
{ name = "kaleido" },
|
| 1579 |
-
{ name = "nnterp" },
|
| 1580 |
{ name = "persona-data" },
|
| 1581 |
{ name = "persona-vectors" },
|
| 1582 |
{ name = "plotly" },
|
| 1583 |
{ name = "python-dotenv" },
|
| 1584 |
{ name = "streamlit" },
|
| 1585 |
-
{ name = "torch" },
|
| 1586 |
-
{ name = "transformers" },
|
| 1587 |
]
|
| 1588 |
|
| 1589 |
[package.metadata]
|
| 1590 |
requires-dist = [
|
| 1591 |
-
{ name = "
|
| 1592 |
-
{ name = "
|
| 1593 |
-
{ name = "persona-data", git = "ssh://git@github.com/implicit-personalization/persona-data.git" },
|
| 1594 |
-
{ name = "persona-vectors", git = "ssh://git@github.com/implicit-personalization/persona-vectors.git" },
|
| 1595 |
{ name = "plotly", specifier = ">=6.6.0" },
|
| 1596 |
{ name = "python-dotenv", specifier = ">=1.2.2" },
|
| 1597 |
{ name = "streamlit", specifier = ">=1.44.0" },
|
| 1598 |
-
{ name = "torch", specifier = ">=2.10.0" },
|
| 1599 |
-
{ name = "transformers", specifier = ">=5.2.0" },
|
| 1600 |
]
|
| 1601 |
|
| 1602 |
[[package]]
|
| 1603 |
name = "persona-vectors"
|
| 1604 |
version = "0.1.0"
|
| 1605 |
-
source = {
|
| 1606 |
dependencies = [
|
| 1607 |
-
{ name = "huggingface-hub" },
|
| 1608 |
{ name = "kaleido" },
|
| 1609 |
{ name = "nnsight" },
|
| 1610 |
{ name = "nnterp" },
|
|
@@ -1621,6 +1620,23 @@ dependencies = [
|
|
| 1621 |
{ name = "umap-learn" },
|
| 1622 |
]
|
| 1623 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1624 |
[[package]]
|
| 1625 |
name = "pexpect"
|
| 1626 |
version = "4.9.0"
|
|
|
|
| 1561 |
[[package]]
|
| 1562 |
name = "persona-data"
|
| 1563 |
version = "0.1.0"
|
| 1564 |
+
source = { editable = "../persona-data" }
|
| 1565 |
dependencies = [
|
| 1566 |
{ name = "huggingface-hub" },
|
| 1567 |
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
|
|
|
|
| 1570 |
{ name = "torch" },
|
| 1571 |
]
|
| 1572 |
|
| 1573 |
+
[package.metadata]
|
| 1574 |
+
requires-dist = [
|
| 1575 |
+
{ name = "huggingface-hub", specifier = ">=0.30.0" },
|
| 1576 |
+
{ name = "numpy", specifier = ">=1.24.0" },
|
| 1577 |
+
{ name = "python-dotenv", specifier = ">=1.0.0" },
|
| 1578 |
+
{ name = "torch", specifier = ">=2.0.0" },
|
| 1579 |
+
]
|
| 1580 |
+
|
| 1581 |
[[package]]
|
| 1582 |
name = "persona-ui"
|
| 1583 |
version = "0.1.0"
|
| 1584 |
source = { virtual = "." }
|
| 1585 |
dependencies = [
|
|
|
|
|
|
|
| 1586 |
{ name = "persona-data" },
|
| 1587 |
{ name = "persona-vectors" },
|
| 1588 |
{ name = "plotly" },
|
| 1589 |
{ name = "python-dotenv" },
|
| 1590 |
{ name = "streamlit" },
|
|
|
|
|
|
|
| 1591 |
]
|
| 1592 |
|
| 1593 |
[package.metadata]
|
| 1594 |
requires-dist = [
|
| 1595 |
+
{ name = "persona-data", editable = "../persona-data" },
|
| 1596 |
+
{ name = "persona-vectors", editable = "../persona-vectors" },
|
|
|
|
|
|
|
| 1597 |
{ name = "plotly", specifier = ">=6.6.0" },
|
| 1598 |
{ name = "python-dotenv", specifier = ">=1.2.2" },
|
| 1599 |
{ name = "streamlit", specifier = ">=1.44.0" },
|
|
|
|
|
|
|
| 1600 |
]
|
| 1601 |
|
| 1602 |
[[package]]
|
| 1603 |
name = "persona-vectors"
|
| 1604 |
version = "0.1.0"
|
| 1605 |
+
source = { editable = "../persona-vectors" }
|
| 1606 |
dependencies = [
|
|
|
|
| 1607 |
{ name = "kaleido" },
|
| 1608 |
{ name = "nnsight" },
|
| 1609 |
{ name = "nnterp" },
|
|
|
|
| 1620 |
{ name = "umap-learn" },
|
| 1621 |
]
|
| 1622 |
|
| 1623 |
+
[package.metadata]
|
| 1624 |
+
requires-dist = [
|
| 1625 |
+
{ name = "kaleido", specifier = ">=1.0.0" },
|
| 1626 |
+
{ name = "nnsight", specifier = ">=0.6.1" },
|
| 1627 |
+
{ name = "nnterp", specifier = ">=1.3.0" },
|
| 1628 |
+
{ name = "persona-data", editable = "../persona-data" },
|
| 1629 |
+
{ name = "plotly", specifier = ">=6.6.0" },
|
| 1630 |
+
{ name = "python-dotenv", specifier = ">=1.2.2" },
|
| 1631 |
+
{ name = "safetensors", specifier = ">=0.7.0" },
|
| 1632 |
+
{ name = "scikit-learn", specifier = ">=1.6.0" },
|
| 1633 |
+
{ name = "torch", specifier = ">=2.10.0" },
|
| 1634 |
+
{ name = "torchvision", specifier = ">=0.26.0" },
|
| 1635 |
+
{ name = "tqdm", specifier = ">=4.67.3" },
|
| 1636 |
+
{ name = "transformers", specifier = ">=5.2.0" },
|
| 1637 |
+
{ name = "umap-learn", specifier = ">=0.5.7" },
|
| 1638 |
+
]
|
| 1639 |
+
|
| 1640 |
[[package]]
|
| 1641 |
name = "pexpect"
|
| 1642 |
version = "4.9.0"
|