An open API service indexing awesome lists of open source software.

https://github.com/celvoxes/thinkr

gpt-o1 like chain of thoughts with local LLMs in R
https://github.com/celvoxes/thinkr

chainofthought cot llm ollama r

Last synced: about 2 months ago
JSON representation

gpt-o1 like chain of thoughts with local LLMs in R

Awesome Lists containing this project

README

        

---
title: "thinkR"
output: github_document
---

![](logo.webp)

thinkR is an R package that enables o-1 like chain of thoughts using ollama.

## Installation

To install ceLLama, use the following command:
```{r eval=FALSE}
devtools::install_github("eonurk/thinkR")
```

## Usage

#### Step 1: Install Ollama

Download [`Ollama`](https://ollama.com/).

#### Step 2: Choose Your Model

Select your preferred model. For instance, to run the Llama3 model, use the following terminal command:

```{bash eval=FALSE}
ollama run llama3.1
```

This initiates a local server, which can be verified by visiting http://localhost:11434/. The page should display "Ollama is running".

#### Step 3: Think!

> Q: How many 'R's are in strawberry?
```{r cache=TRUE, eval=FALSE}
library(thinkR)

## Usage example
ollama <- OllamaHandler$new(model = "llama3.1")
result <- generate_response("How many 'R's are in strawberry?", ollama)
```

Thinking...
```{r echo=FALSE}
result <- readRDS("llama3_1.results.rds")

cat(paste0(
sapply(result$steps, function(m) {
if (!is.null(m$title) && !is.null(m$content) && !is.null(m$thinking_time)) {
sprintf("%s\n%s\nTime: %s s\n\n", m$title, m$content, m$thinking_time)
}
}, USE.NAMES = FALSE)
))
```

```{r echo=FALSE}
total_thinking_time <- result$total_thinking_time
cat(paste0("Total thinking time: ", sprintf("%.2f", total_thinking_time), " s"))
```

> A: Therefore, the final answer is 3!


> [!NOTE]\
> This output is cherry-picked from llama3.1... because 70b was a lot to download for my internet connection.

## Acknowledgments

Cursor is a great tool <3

### Credits
- [g-1](https://github.com/bklieger-groq/g1)
- [multi-1](https://github.com/tcsenpai/multi1)

## License
This project is licensed under the MIT License