-
Notifications
You must be signed in to change notification settings - Fork 1k
New modules: Llamacpp-python/run and huggingface/download for allowing to run simple text workloads with local LLMs #11053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 29 commits
7f1b7d7
9031f48
04cd556
537a891
20b5d26
c9997f5
5035e82
2c796de
4f64bac
ff7039c
7a3f8fc
fb1768c
ac7f44c
26168b7
6dfff97
2d171ca
ee04a27
3021074
4630e5a
53c7826
4156db0
421603e
af5eadd
02d3f6d
297f503
ac61a56
ca4721b
8fdffea
9a0d9f3
d65181d
cd3d1b9
fb81365
6f2affa
dfadccb
1dbb3e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| dependencies: | ||
| - conda-forge::huggingface_hub=1.6.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| process HUGGINGFACE_DOWNLOAD { | ||
| tag "${meta.id}" | ||
| label 'process_medium' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "community.wave.seqera.io/library/huggingface_hub:1.6.0--c106a7f9664ca39b" | ||
|
|
||
| input: | ||
| tuple val(meta), val(hf_repo), val(hf_file), val(hf_home) | ||
|
|
||
| output: | ||
| tuple val(meta), path(hf_file), emit: output | ||
| tuple val("${task.process}"), val("huggingface_hub"), eval("hf --version 2>&1 | tail -n1 | awk '{print \$NF}'"), topic: versions, emit: versions_huggingface_hub | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
| def hf_home_resolved = hf_home ?: "${workflow.workDir}/hf_cache" | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| export HF_HOME="${hf_home_resolved}" | ||
| export HF_HUB_CACHE=\$HF_HOME | ||
| hf download ${hf_repo} ${hf_file} --local-dir \$PWD | ||
| """ | ||
|
|
||
| stub: | ||
| """ | ||
| touch ${hf_file} | ||
toniher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: huggingface_download | ||
| description: Command-line interface for downloading models in GGUF format from Hugging Face Hub | ||
| keywords: | ||
| - ai | ||
| - gguf | ||
| - llama | ||
| - llm | ||
| tools: | ||
| - huggingface_hub: | ||
| description: "Command-line interface for interacting with Hugging Face Hub, allowing to download, upload and interact with models and datasets" | ||
| homepage: "https://huggingface.co/docs/huggingface_hub/guides/cli" | ||
| licence: | ||
| - "MIT" | ||
| identifier: "" | ||
| input: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`- prompt_file: | ||
| - hf_repo: | ||
| type: string | ||
| description: Hugging Face repository | ||
| - hf_file: | ||
| type: string | ||
| description: Hugging Face GGUF file | ||
| - hf_home: | ||
| type: string | ||
| description: Hugging Face default cache directory | ||
| output: | ||
| output: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]` | ||
| - hf_file: | ||
| type: file | ||
| description: Downloaded Hugging Face GGUF file | ||
| ontologies: [] | ||
| versions_huggingface_hub: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - huggingface_hub: | ||
| type: string | ||
| description: The name of the tool | ||
| - hf --version 2>&1 | tail -n1 | awk '{print \$NF}': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| topics: | ||
| versions: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - huggingface_hub: | ||
| type: string | ||
| description: The name of the tool | ||
| - hf --version 2>&1 | tail -n1 | awk '{print \$NF}': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| authors: | ||
| - "@toniher" | ||
| - "@lucacozzuto" | ||
| maintainers: | ||
| - "@toniher" | ||
| - "@lucacozzuto" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| nextflow_process { | ||
|
|
||
| name "Test Process HUGGINGFACE_DOWNLOAD" | ||
| script "../main.nf" | ||
| process "HUGGINGFACE_DOWNLOAD" | ||
|
|
||
| tag "modules" | ||
| tag "modules_nfcore" | ||
| tag "huggingface" | ||
| tag "huggingface/download" | ||
|
|
||
| test("download gguf file - gemma3") { | ||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id:'test_model_gemma3' ], | ||
| "ggml-org/gemma-3-1b-it-GGUF", | ||
| "gemma-3-1b-it-Q4_K_M.gguf", | ||
| "./hf_cache" | ||
| ] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert process.out.output.size() == 1 }, | ||
| { assert process.out.output[0][0] == [ id:'test_model_gemma3' ] }, | ||
| { assert file(process.out.output[0][1]).name == "gemma-3-1b-it-Q4_K_M.gguf" }, | ||
| { assert file(process.out.output[0][1]).size() > 0 }, | ||
| { assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match() } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| test("download gguf file - smollm3") { | ||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id:'test_model_smollm3' ], | ||
| "unsloth/SmolLM3-3B-GGUF", | ||
| "SmolLM3-3B-UD-IQ2_XXS.gguf", | ||
| "./hf_cache" | ||
| ] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert process.out.output.size() == 1 }, | ||
| { assert process.out.output[0][0] == [ id:'test_model_smollm3' ] }, | ||
| { assert file(process.out.output[0][1]).name == "SmolLM3-3B-UD-IQ2_XXS.gguf" }, | ||
| { assert file(process.out.output[0][1]).size() > 0 }, | ||
| { assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match() } | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| } | ||
| } | ||
|
|
||
| test("stub - download gguf file - gemma3") { | ||
|
|
||
| options "-stub" | ||
|
|
||
| when { | ||
| process { | ||
| """ | ||
| input[0] = [ | ||
| [ id:'test_model_gemma3' ], | ||
| "ggml-org/gemma-3-1b-it-GGUF", | ||
| "gemma-3-1b-it-Q4_K_M.gguf", | ||
| "./hf_cache" | ||
| ] | ||
| """ | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
| { assert snapshot(sanitizeOutput(process.out)).match() } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| { | ||
| "stub - download gguf file - gemma3": { | ||
| "content": [ | ||
| { | ||
| "output": [ | ||
| [ | ||
| { | ||
| "id": "test_model_gemma3" | ||
| }, | ||
| "gemma-3-1b-it-Q4_K_M.gguf:md5,d41d8cd98f00b204e9800998ecf8427e" | ||
| ] | ||
| ], | ||
| "versions_huggingface_hub": [ | ||
| [ | ||
| "HUGGINGFACE_DOWNLOAD", | ||
| "huggingface_hub", | ||
| "1.6.0" | ||
| ] | ||
| ] | ||
| } | ||
| ], | ||
| "timestamp": "2026-04-04T22:00:17.896195894", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.10.4" | ||
| } | ||
| }, | ||
| "download gguf file - gemma3": { | ||
| "content": [ | ||
| { | ||
| "versions_huggingface_hub": [ | ||
| [ | ||
| "HUGGINGFACE_DOWNLOAD", | ||
| "huggingface_hub", | ||
| "1.6.0" | ||
| ] | ||
| ] | ||
| } | ||
| ], | ||
| "timestamp": "2026-04-04T21:36:18.125789808", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.10.4" | ||
| } | ||
| }, | ||
| "download gguf file - smollm3": { | ||
| "content": [ | ||
| { | ||
| "versions_huggingface_hub": [ | ||
| [ | ||
| "HUGGINGFACE_DOWNLOAD", | ||
| "huggingface_hub", | ||
| "1.6.0" | ||
| ] | ||
| ] | ||
| } | ||
| ], | ||
| "timestamp": "2026-04-04T21:55:38.228583826", | ||
| "meta": { | ||
| "nf-test": "0.9.5", | ||
| "nextflow": "25.10.4" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| process { | ||
famosab marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| withName: 'HUGGINGFACE_DOWNLOAD' { | ||
| containerOptions = { workflow.profile.contains('docker') ? "--volume ${workDir}/hf_cache:${workDir}/hf_cache" : '' } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this tool is on conda-forge, you don't need to add a dockerfile, just use seqera containers https://nf-co.re/docs/developing/containers/seqera-containers
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am actually using seqera containers for no gpu situations. https://seqera.io/containers/?packages=conda-forge::llama-cpp-python=0.3.16 I understand I could approach it similarly as here: modules/modules/nf-core/multiqc/meta.yml Line 110 in dd6396b
Until there is any better solution, I could enable when it is, at the same time containers, accelerator (and amd64?) to use |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 | ||
|
|
||
| RUN apt-get update && apt-get install -y python3 python3-pip | ||
| RUN pip3 install llama-cpp-python \ | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - conda-forge::llama-cpp-python=0.3.16 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| process LLAMACPPPYTHON_RUN { | ||
| tag "${meta.id}" | ||
| label 'process_medium' | ||
| label 'process_gpu' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${task.ext.use_gpu ? 'quay.io/nf-core/llama-cpp-python:0.1.9' : 'community.wave.seqera.io/library/llama-cpp-python:0.3.16--b351398cd0ea7fc5'}" | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| input: | ||
| tuple val(meta), path(prompt_file), path(gguf_model) | ||
|
|
||
| output: | ||
| tuple val(meta), path("${prefix}.txt"), emit: output | ||
| tuple val("${task.process}"), val("llama-cpp-python"), eval("python3 -c 'import llama_cpp; print(llama_cpp.__version__)'"), topic: versions, emit: versions_llama_cpp_python | ||
|
|
||
| when: | ||
| task.ext.when == null || task.ext.when | ||
|
|
||
| script: | ||
toniher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def args = task.ext.args ?: '' | ||
| prefix = task.ext.prefix ?: "${meta.id}" | ||
| """ | ||
| llama-cpp-python.py \ | ||
| --model ${gguf_model} \ | ||
| --messages ${prompt_file} \ | ||
| --output ${prefix}.txt \ | ||
| ${args} | ||
| """ | ||
|
|
||
| stub: | ||
| prefix = task.ext.prefix ?: "${meta.id}" | ||
| """ | ||
| touch ${prefix}.txt | ||
| """ | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: llamacpppython_run | ||
| description: Python wrapper for running locally-hosted LLM with llama.cpp | ||
| keywords: | ||
toniher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - ai | ||
toniher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - inference | ||
| - llama | ||
| - llm | ||
| - local-inference | ||
| - offline-llm | ||
| tools: | ||
| - llama-cpp-python: | ||
| description: "Python wrapper for llama.cpp LLM inference tool" | ||
| homepage: "https://llama-cpp-python.readthedocs.io/en/latest/" | ||
| licence: | ||
| - "MIT" | ||
| identifier: "" | ||
| input: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]`- prompt_file: | ||
| - prompt_file: | ||
| type: file | ||
| description: | | ||
| Prompt file | ||
| Structure: [ val(meta), path(prompt_file) ] | ||
| ontologies: [] | ||
| - gguf_model: | ||
| type: file | ||
| description: | | ||
| GGUF model | ||
| Structure: [ val(meta), path(gguf_model) ] | ||
| ontologies: [] | ||
| output: | ||
| output: | ||
| - - meta: | ||
| type: map | ||
| description: | | ||
| Groovy Map containing sample information | ||
| e.g. `[ id:'sample1' ]` | ||
| - ${prefix}.txt: | ||
| type: file | ||
| description: File with the output of LLM inference request | ||
| ontologies: [] | ||
| versions_llama_cpp_python: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - llama-cpp-python: | ||
| type: string | ||
| description: The name of the tool | ||
| - python3 -c 'import llama_cpp; print(llama_cpp.__version__)': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| topics: | ||
| versions: | ||
| - - ${task.process}: | ||
| type: string | ||
| description: The name of the process | ||
| - llama-cpp-python: | ||
| type: string | ||
| description: The name of the tool | ||
| - python3 -c 'import llama_cpp; print(llama_cpp.__version__)': | ||
| type: eval | ||
| description: The expression to obtain the version of the tool | ||
| authors: | ||
| - "@toniher" | ||
| - "@lucacozzuto" | ||
| maintainers: | ||
| - "@toniher" | ||
| - "@lucacozzuto" | ||
Uh oh!
There was an error while loading. Please reload this page.