transformers gguf text-generation license:gemma endpoints_compatible region:us conversational
---
library_name: transformers
license: gemma
pipeline_tag: text-generation
widget:
- messages:
  - role: user
    content: How does the brain work?
inference:
  parameters:
    max_new_tokens: 200
extra_gated_heading: Access Gemma on Hugging Face
extra_gated_prompt: To access Gemma on Hugging Face, you’re required to review and
  agree to Google’s usage license. To do this, please ensure you’re logged-in to Hugging
  Face and click below. Requests are processed immediately.
extra_gated_button_content: Acknowledge license
quantized_by: bartowski
lm_studio:
  param_count: 2b
  use_case: general
  release_date: 05-04-2024
  model_creator: google
  prompt_template: Google Gemma Instruct
  system_prompt: none
  base_model: gemma
  original_repo: google/gemma-1.1-2b-it
---

## 💫 Community Model> Gemma 1.1 2b Instruct by Google

*👾 [LM Studio](https://lmstudio.ai) Community models highlights program. Highlighting new & noteworthy models by the community. Join the conversation on [Discord](https://discord.gg/aPQfnNkxGC)*.

**Model creator:** [Google](https://huggingface.co/google)<br>
**Original model**: [gemma-1.1-2b-it](https://huggingface.co/google/gemma-1.1-2b-it)<br>
**GGUF quantization:** provided by [bartowski](https://huggingface.co/bartowski) based on `llama.cpp` release [b2589](https://github.com/ggerganov/llama.cpp/releases/tag/b2589)<br>

## Model Summary:
Gemma 1.1 instruct is a followup to Google's initial Gemma release. Compared to the first iteration, this model features substantial gains in quality, coding capabilities, factuality, instruction following and multi-turn conversation quality.<br>
As an instruction following model, this can be used for any number of use cases, including conversation and coding.<br>
At only 2b parameters, this model is great for people with low resources or who want an extremely fast response time for things like autocomplete or just generally rapid replies, while still giving extremely coherent answers.<br>
This model tends to reply in a more educational style, rather than truly conversational as you might expect, but does provide very thorough and detailed answers.

## Prompt Template:

Choose the 'Google Gemma Instruct' preset in your LM Studio. 

Under the hood, the model will see a prompt that's formatted like so:

```
<start_of_turn>user
{prompt}<end_of_turn>
<start_of_turn>model
```

Note that this model does not support a System prompt.

## Use case and examples

The Gemma series of models is at its best when used for creativity, question answering, multi turn conversations, and coding.

### Creativity

```
<start_of_turn>user
Write me a poem about Machine Learning.<end_of_turn>
<start_of_turn>model
**Machine Learning**

In circuits deep, where data flows,
Algorithms dance, a wondrous show.
Machines learn, from vast and wide,
Insights hidden, in patterns tied.

From pixels seen, to words untold,
Insights emerge, stories unfold.
Through neural nets, a symphony of thought,
Connecting knowledge, a digital lot.

Data as fuel, a constant flow,
Learning patterns, ever low.
From regression's line to classification's task,
Machine learning unlocks a wondrous space.

In healthcare, it diagnoses with grace,
Predicting outcomes, with uncanny pace.
In finance, it guides investment wise,
Optimizing portfolios, with uncanny guise.

From self-driving cars to medical aid,
Machine learning's impact cannot be swayed.
It revolutionizes, with each passing day,
A future bright, where possibilities sway.

So let us embrace this wondrous art,
Machine learning, a gift from the start.
For in its depths, a world unseen,
Where knowledge and progress are truly keen.<end_of_turn>
```

### Coding

Note, the following code works if you move the partition function above the quicksort function, but original model output provided below for accuracy.

```
<start_of_turn>user
Implement quicksort using C++<end_of_turn>
<start_of_turn>model

    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    void quicksort(vector<int>& arr, int low, int high)
    {
        if (low < high)
        {
            int partition_index = partition(arr, low, high);
    
            quicksort(arr, low, partition_index - 1);
            quicksort(arr, partition_index + 1, high);
        }
    }
    
    int partition(vector<int>& arr, int low, int high)
    {
        int pivot = arr[high];
        int i = (low - 1);
    
        for (int j = low; j < high; j++)
        {
            if (arr[j] < pivot)
            {
                i++;
    
                swap(arr[i], arr[j]);
            }
        }
    
        swap(arr[i + 1], arr[high]);
        return (i + 1);
    }
    
    int main()
    {
        vector<int> arr = {6, 4, 2, 8, 1, 5, 3, 7, 9};
    
        cout << "Unsorted array: ";
        for (int element : arr)
        {
            cout << element << " ";
        }
    
        quicksort(arr, 0, arr.size() - 1);
    
        cout << endl;
    
        cout << "Sorted array: ";
        for (int element : arr)
        {
            cout << element << " ";
        }
    
        return 0;
    }


**Explanation:**

* The `quicksort()` function recursively divides the array into smaller parts until the subarrays become empty.
* The `partition()` function selects a pivot element and partitions the array into two subarrays: elements smaller than the pivot go to the left subarray, and elements greater than the pivot go to the right subarray.
* The pivot element is swapped with the element in the right subarray.

**Time Complexity:**

* Best case: O(n log n)
* Average case: O(n log n)
* Worst case: O(n^2)

**Space Complexity:**

* O(1) for the recursive call stack.
* O(n) for the temporary storage used during the partitioning.<end_of_turn>
```

### Conversational

```
<bos><start_of_turn>user
How does the brain work?<end_of_turn>
<start_of_turn>model
**The brain is a complex organ with billions of neurons and synapses that work together to control all bodily functions.**

**Structure of the Brain:**

* **Neurons:** Basic functional units of the brain that transmit electrical signals.
* **Synapses:** Points of contact between neurons where chemical or electrical signals are transferred.
* **Dendrites:** Extensions of neurons that receive signals.
* **Axons:** Extensions of neurons that transmit signals away from the brain.

**Function of the Brain:**

**1. Sensory Function:**
* Receiving and interpreting sensory information from the body and environment.
* Processing and interpreting sensory data.

**2. Motor Function:**
* Sending signals to muscles to control movement.
* Coordinating and regulating muscle activity.

**3. Cognitive Function:**
* Thinking, memory, language, and problem-solving.
* Using information from the senses to form mental representations.

**4. Emotional Function:**
* Regulating emotions and feelings.
* Processing and expressing emotions.

**5. Sensory-Motor Integration:**
* Coordinating sensory and motor functions to maintain balance and posture.

**Processes in the Brain:**

**1. Neurotransmission:**
* Electrical or chemical signals are sent across synapses.
* Neurotransmitters are chemicals that cross synaptic gaps to excite or inhibit neurons.

**2. Signal Processing:**
* Neurons receive and process signals from other neurons.
* They use this information to generate their own electrical or chemical signals.

**3. Learning and Memory:**
* The brain forms memories through repeated experiences.
* Memories are stored in the brain and can be used to guide behavior and decision-making.

**4. Adaptation:**
* The brain can adapt to new experiences and stimuli.
* This process is essential for learning and survival.

**5. Homeostasis:**
* The brain maintains the body's internal balance.
* It regulates body temperature, blood sugar levels, and other vital functions.

**Factors Influencing Brain Function:**

* Genetics
* Environment
* Experience
* Sleep
* Nutrition
* Stress

**Conclusion:**

The brain is a remarkable organ that allows humans to experience the world, think, and move. Understanding how the brain works is essential for understanding human health and disease.<end_of_turn>
<start_of_turn>user
What influence does sleep have on the brain?<end_of_turn>
<start_of_turn>model
**Sleep exerts a profound influence on the brain, playing a crucial role in various cognitive, physiological, and emotional processes.**

**Cognitive effects:**

* Enhanced memory consolidation and retention
* Improved attention and focus
* Increased creativity and innovation
* Reduced risk of cognitive decline and dementia

**Physiological effects:**

* Restoration of cellular and synaptic plasticity
* Regulation of neurotransmitter activity
* Increased production of growth hormone and other hormones
* Reduced inflammation and oxidative stress

**Emotional effects:**

* Reduced emotional reactivity and stress levels
* Improved mood and emotional regulation
* Increased resilience to stress
* Enhanced empathy and social connection

**Neurobiological mechanisms:**

* **Memory consolidation:** Sleep promotes the consolidation of memories through the formation of new synaptic connections.
* **Neurotransmitter regulation:** Sleep helps regulate the levels of various neurotransmitters, including dopamine, serotonin, and glutamate.
* **Cellular repair and growth:** Sleep promotes the repair and growth of neurons and other brain cells.
* **Synaptic plasticity:** Sleep is essential for the formation and strengthening of new synapses, which is crucial for learning and memory.

**Specific functions of sleep:**

* **Rapid eye movement (REM) sleep:** Associated with dreaming and emotional processing.
* **Slow-wave sleep:** Involved in restorative processes, such as tissue repair and hormone production.
* **Deep sleep:** Essential for memory consolidation and emotional regulation.

**Benefits of adequate sleep:**

* Improved cognitive function and academic performance
* Reduced risk of chronic diseases
* Increased resilience to stress
* Enhanced mood and emotional well-being
* Improved physical health

**Consequences of poor sleep:**

* Difficulty concentrating and remembering information
* Increased risk of accidents and errors
* Emotional instability and irritability
* Cognitive decline and dementia<end_of_turn>
```

## Technical Details

Gemma 1.1 2B instruct is tuned using a novel Reinforced Learning through Human Feedback (RLHF) approach, leading to its noted gains over the first release.

Gemma also has an extremely large vocabulary, which tends to help with multilingual and coding proficiency.

Gemma was trained on a wide dataset of 6 trillion tokens, including:

- Web Documents: A diverse collection of web text ensures the model is exposed to a broad range of linguistic styles, topics, and vocabulary. Primarily English-language content.
- Code: Exposing the model to code helps it to learn the syntax and patterns of programming languages, which improves its ability to generate code or understand code-related questions.
- Mathematics: Training on mathematical text helps the model learn logical reasoning, symbolic representation, and to address mathematical queries.

## Special thanks

🙏 Special thanks to [Georgi Gerganov](https://github.com/ggerganov) and the whole team working on [llama.cpp](https://github.com/ggerganov/llama.cpp/) for making all of this possible.

## Disclaimers

LM Studio is not the creator, originator, or owner of any Model featured in the Community Model Program. Each Community Model is created and provided by third parties. LM Studio does not endorse, support, represent or guarantee the completeness, truthfulness, accuracy, or reliability of any Community Model.  You understand that Community Models can produce content that might be offensive, harmful, inaccurate or otherwise inappropriate, or deceptive. Each Community Model is the sole responsibility of the person or entity who originated such Model. LM Studio may not monitor or control the Community Models and cannot, and does not, take responsibility for any such Model. LM Studio disclaims all warranties or guarantees about the accuracy, reliability or benefits of the Community Models.  LM Studio further disclaims any warranty that the Community Model will meet your requirements, be secure, uninterrupted or available at any time or location, or error-free, viruses-free, or that any errors will be corrected, or otherwise. You will be solely responsible for any damage resulting from your use of or access to the Community Models, your downloading of any Community Model, or use of any other Community Model provided by or through LM Studio.
