-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
69 lines (54 loc) · 1.8 KB
/
README.Rmd
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
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rchroma <a href="https://cynkra.github.io/rchroma/"><img src="man/figures/logo.png" align="right" height="139" alt="rchroma website" /></a>
<!-- badges: start -->
[](https://github.com/cynkra/rchroma/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/cynkra/rchroma?branch=main)
<!-- badges: end -->
rchroma provides a clean interface to [ChromaDB](https://www.trychroma.com/), a modern vector database for storing and querying embeddings.
## Installation
You can install rchroma from GitHub:
```{r eval = FALSE}
# install.packages("remotes")
remotes::install_github("cynkra/rchroma")
```
You also need a running ChromaDB instance. The easiest way to get started is using Docker:
```bash
docker pull chromadb/chroma
docker run -p 8000:8000 chromadb/chroma
```
See the [ChromaDB documentation](https://docs.trychroma.com/docs/overview/introduction) for other installation methods.
## Usage
```{r eval = FALSE}
library(rchroma)
# Connect to ChromaDB
client <- chroma_connect()
# Create a collection and add documents with embeddings
create_collection(client, "my_collection")
add_documents(
client,
"my_collection",
documents = c("apple", "banana"),
ids = c("doc1", "doc2"),
embeddings = list(
c(1.0, 0.0), # apple
c(0.8, 0.2) # banana (similar to apple)
)
)
# Query similar documents using embeddings
query(
client,
"my_collection",
query_embeddings = list(c(1.0, 0.0)), # should match apple best
n_results = 2
)
```