1. 25 Sep, 2025 1 commit
    • Devon Rifkin's avatar
      parsers: fix unicode handling for qwen3-coder · 05ba4ca1
      Devon Rifkin authored
      When trimming whitespace at the end of every chunk, we were iterating
      backwards over the string byte-by-byte instead of rune-by-rune.
      
      As an example of how this can cause corruption, suppose we have the
      multi-byte character  (`"\u2705"`), which is represented in utf-8 as
      the three bytes `0xE2 0x9C 0x85`. It happens that `0x85` is NEL, which
      passes `unicode.IsSpace()`. Because we were iterating byte-by-byte, this
      caused us to mistakenly slice in the middle of the rune, removing `0x85`
      and leaving `0xE2 0x9C`, which beyond being the incorrect place to
      slice, is not even a valid utf-8 character.
      
      `trailingWhitespaceLen()` was modified to count from the end in a
      rune-aware way. Tests with various multibyte unicode characters were
      also added.
      
      
      Fixes: #12414
      05ba4ca1
  2. 24 Sep, 2025 5 commits
    • Grace's avatar
      Grace/deepseek v3 migration (#12385) · fbd82ba5
      Grace authored
      
      
      * init deepseek model file
      
      * temp removal of flash attention implementation
      
      * shapes and proper, can make a pass
      
      * query, key, value have good cosine similarity, but the max diff is a bit high
      
      * Attention block is working! ** with eager for now, have not added the mask line
      
      * Attention block is working! ** with eager for now, have not added the mask line
      
      * working MoE at around 0.95 cosine sim
      
      * added cosine similarity function
      
      * Starting end to end structure
      
      * Trying (and failing) to get rope to work, going to test full thing on tater
      
      * running on tater36... just not the right outputs
      
      * we have the right values for rope... but its still not working?
      
      * chnage Extrapolation Factor to 1
      
      * removed adding residuals twice, removed normalization from shared expert, refactored Norms (Attention, MLP) to be outside the (Attention, MLP) blocks and in the Transformer block instead, add cache setLayer
      
      * Temporary modelfiles for cpu
      
      * change kpass intermediate step to kv, two layer outputs [0,1] look fine
      
      * this calls for 16 chicken nuggets
      
      * whoops
      
      * cleaning up code
      
      * delete stuff we dont need
      
      * getting rid of debug statements for llama cpp
      
      * working with long contexts
      
      * fix long context view error
      
      * reverting some changes I made for files that are not apart of pr
      
      * Added proper tokenizer for deeepseek3
      
      * clean up model and go test
      
      * remove Modelfile
      
      * not passing the tests
      
      * whoops
      
      * how to pass the ci tests
      
      * resolving some of the comments
      
      * rename
      
      * linted and renamed deepseek3 -> deepseek2
      
      * remove name go
      
      * addressed changes - main change was adopting qwen3 naming scheme
      
      * I cannot with linters
      
      * clean up logs
      
      * clean up logs
      
      ---------
      Co-authored-by: default avatarGrace Guo <graceguo@Graces-MBP.localdomain>
      Co-authored-by: default avatarGrace Guo <graceguo@Graces-MacBook-Pro.local>
      Co-authored-by: default avatargraceguo <graceguo@tater36.localdomain>
      fbd82ba5
    • Michael Yang's avatar
      prefer ollama engine for qwen3moe (#12374) · 2e742544
      Michael Yang authored
      2e742544
    • Devon Rifkin's avatar
      Merge pull request #12393 from ollama/drifkin/fix-built-ins · bbb195a6
      Devon Rifkin authored
      harmony: don't sanitize built-ins
      bbb195a6
    • Devon Rifkin's avatar
      harmony: don't sanitize built-ins · fd88cd7c
      Devon Rifkin authored
      In #11910 we started sanitizing function names, but we accidentally were
      modifying built-ins like `browser.open` to `browser_open`. This was
      removing the special prompt rendering for built-ins, but this wasn't
      immediately apparent since the models seem to be reasonably good at
      remembering the built-ins even when presented with these slightly
      renamed version. This fix prevents built-ins from ever being renamed.
      fd88cd7c
    • Michael Yang's avatar
      fix: leaf alt name (#12390) · e1979c57
      Michael Yang authored
      a leaf node with an alternative name gets all its alternatives names
      added into the same branch rather than creating branches themselves
      e1979c57
  3. 23 Sep, 2025 3 commits
  4. 22 Sep, 2025 4 commits
  5. 20 Sep, 2025 2 commits
    • Devon Rifkin's avatar
      Merge pull request #12358 from ollama/drifkin/qwen3-coder-ampersands · 3677842f
      Devon Rifkin authored
      parsers: fix `&`s in qwen3coder parameter values
      3677842f
    • Devon Rifkin's avatar
      parsers: fix `&`s in qwen3coder parameter values · 242df70a
      Devon Rifkin authored
      In <https://github.com/ollama/ollama/issues/12357> we that the model
      will output tool calls such as
      
      ```
      <function=shell>
      <parameter=command>
      pwd && ls -la
      </parameter>
      </function>
      ```
      
      We parse this using the approach of transforming into valid xml and then
      using an xml parser. While we do transform the function and parameter
      names, we weren't escaping the parameter values (which in this example
      are invalid since `pwd && ls -la` contains unescaped ampersands).
      
      This has been fixed by first transforming the tags in the same way, and
      then walking the transformed string and escaping the text in between the
      tags. This also fixes a case where `<` in the middle of a parameter
      value would cause an xml parse failure.
      
      Fixes: #12357
      242df70a
  6. 19 Sep, 2025 1 commit
  7. 18 Sep, 2025 8 commits
  8. 17 Sep, 2025 6 commits
  9. 16 Sep, 2025 5 commits
  10. 15 Sep, 2025 5 commits
    • Daniel Hiltgen's avatar
      93c64ea1
    • Michael Yang's avatar
      model: implement bert in ollama engine (#9080) · 3f6642f6
      Michael Yang authored
      * fix truncate
      
      * s/SentencePieceModel/SentencePiece/
      
      * bert
      
      * wordpiece
      
      * refactor pooling
      
      * more tokenizers
      
      * normalize embeddings
      3f6642f6
    • Michael Yang's avatar
      batch: use tensors for outputs (#12185) · 6f711714
      Michael Yang authored
      this cleans up the model interface slightly without too much impact in
      other areas
      6f711714
    • Devon Rifkin's avatar
      address comments · 472feec2
      Devon Rifkin authored
      472feec2
    • Devon Rifkin's avatar
      add qwen3-coder tool support · 47991940
      Devon Rifkin authored
      The format qwen3-coder uses is relatively unique, both in rendering and
      in parsing. To implement parsing, I wrote a custom parser in similar
      style to harmony. For the rendering, I found that the logic would be
      much more difficult to follow in a template, so I introduced the concept
      of a built-in renderer that uses go code, rather than a template to
      generate prompts.
      
      I set us up for future built-in parsers and renderers by making it so
      they can be specified in a Modelfile like so:
      
      ```
      RENDERER "qwen3-coder"
      PARSER "qwen3-coder"
      ```
      
      These need to be provided explicitly because the architecture alone is
      not enough to understand what format the model expects to receive, and
      what format we expect it to output (e.g., qwen3-coder is `qwen3moe`,
      which includes other qwen3-family models as well)
      
      I haven't converted harmony to be one of these "built-ins" yet, since
      some of it is in flux with the changes @ParthSareen has been making to
      move harmony to the runner. It is likely that many other built-ins will
      need to move to the runner as well, but I'm able to slightly defer that
      decision since qwen3-coder doesn't have thinking (and therefore doesn't
      need to be in the runner to make structured outputs work). I expect to
      unify harmony with this approach very soon.
      
      Whether a particular model supports tools or thinking was previously
      inferred from templates, but without a template we now also use the
      parser itself to declare what it supports. If we have future models that
      re-use the same parsing format, but have different capabilities, we'll
      want to parameterize them and give them different names to be specified
      as a `PARSER`.
      
      Misc changes:
      
      - I worked on the renderer by diffing outputs from the reference
        implementation and ours. To make it easier to do this, I extended
        <https://github.com/ollama/ollama/pull/11875> to also support
        returning the prompt via the openai compat layer
      47991940