# LM Studio

## Overview

* LM Studio provides a way to run LLMs locally on your machine
* It's similar to [Ollama](/ai/running-llms-locally/ollama.md)but provides a GUI interface making it more user-friendly and also similar in style to ChatGPT

***

## Installation

{% code overflow="wrap" %}

```bash
brew install lm-studio
```

{% endcode %}

***

## Running LM Studio

{% hint style="warning" %}
These models are loaded into your system's memory (RAM) when in `READY` state so be cognizant of usage
{% endhint %}

* Open the app and hit `CMD + L` to select a model to use
* Then wait for the model to load i.e., `READY` state

<figure><img src="/files/0WvZ4N1lnUZq7ZA7ohYh" alt=""><figcaption></figcaption></figure>

* Click the `Eject` button (seen above) to unload the model from memory

***

## Discovering and Downloading Models

* Models are downloaded from [Hugging Face](https://huggingface.co/)
* Models are downloaded here `~/.lmstudio/models/`
* Open the app and hit `CMD + SHIFT + M`&#x20;

<figure><img src="/files/xODlVCBPWpIgbG70n7ce" alt=""><figcaption></figcaption></figure>

* By selecting the below option, we can ensure models will fit on our device (based on memory)

<figure><img src="/files/uhjl8OQaLvR5s5KleIGI" alt=""><figcaption></figcaption></figure>

***

## Integrating with VS Code

### Start LM Studio Server

<figure><img src="/files/zizaSdjYLmrxbeedFO3b" alt=""><figcaption></figcaption></figure>

***

### Install VS Code Extension, Continue

* The most straightforward way I've found is by installing the [VS Code extension, continue](https://marketplace.visualstudio.com/items?itemName=Continue.continue)&#x20;
* While this is a 3rd-party coding assistant, the extension is open-source and we can entirely leverage our local LLMs without signing up for this service

<figure><img src="/files/0uCX0bRnte7VPyGm5bVO" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/XkKRXL3okC0M0tbbinMv" alt=""><figcaption></figcaption></figure>

* Open up a file e.g. `main.tf` and hit `CTRL + I`&#x20;
* This opens the chat window on the side where you can type in what you want the LLM to write for you

<figure><img src="/files/qyktMtT8SIXUp76VLGVo" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.techwithtyler.dev/ai/running-llms-locally/lm-studio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
