Created
December 22, 2025 06:51
-
-
Save agricolamz/e9f8fa54db1d1911b51172a71056600e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(ragnar) | |
| # creating a store -------------------------------------------------------- | |
| ragnar_store_create( | |
| location = "english_linguistic_abstract", | |
| overwrite = TRUE, | |
| version = 1, | |
| embed = function(x){ragnar::embed_ollama(x, model = "embeddinggemma")}, | |
| extra_cols = data.frame(author = character(), | |
| title = character(), | |
| journal = character(), | |
| volume = character(), | |
| issue = charactezr(), | |
| publication_year = character(), | |
| first_page = character(), | |
| last_page = character(), | |
| doi = character())) -> | |
| store | |
| read_csv("data/2024-04-22.csv", show_col_types = FALSE) |> # путь к одному файлу с аннотациями | |
| select(doi, author, title, publication_year, first_page, last_page, volume, issue, journal_issn, abstract) |> | |
| rename(journal = journal_issn, | |
| text = abstract) |> | |
| mutate_all(as.character) |> | |
| mutate_all(function(x) ifelse(is.na(x), "-", x)) |> | |
| ragnar_store_insert(store, chunks = _) | |
| ragnar_store_build_index(store) | |
| # retrieving from the store ----------------------------------------------- | |
| store <- ragnar_store_connect("english_linguistic_abstract") | |
| ragnar_store_inspect(store) | |
| ragnar_retrieve_vss(store, | |
| method = "cosine_distance", | |
| deoverlap = FALSE, | |
| top_k = 20, | |
| query = "number", | |
| filter = author == "Akira Watanabe") |> | |
| select(-embedding, -hash, -metric_name, -origin) |> | |
| relocate(text, .before = "author") |> | |
| relocate(title, .before = "author") |> | |
| arrange(metric_value) |> | |
| View() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment