cohere-transcribe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +201 -0
- data/NOTICE +5 -0
- data/README.md +265 -0
- data/THIRD_PARTY_NOTICES.md +67 -0
- data/exe/cohere-transcribe +8 -0
- data/exe/cohere-transcribe-doctor +8 -0
- data/ext/cohere_transcribe_native/CMakeLists.txt +262 -0
- data/ext/cohere_transcribe_native/README.md +26 -0
- data/ext/cohere_transcribe_native/audio_abi.cpp +1416 -0
- data/ext/cohere_transcribe_native/audio_exports.macos +5 -0
- data/ext/cohere_transcribe_native/audio_exports.map +10 -0
- data/ext/cohere_transcribe_native/cohere_abi.cpp +1209 -0
- data/ext/cohere_transcribe_native/exports.macos +40 -0
- data/ext/cohere_transcribe_native/exports.map +45 -0
- data/ext/cohere_transcribe_native/extconf.rb +89 -0
- data/ext/cohere_transcribe_native/test/abi_smoke.rb +232 -0
- data/ext/cohere_transcribe_native/test/audio_matrix_smoke.cpp +121 -0
- data/ext/cohere_transcribe_native/test/audio_reliability_smoke.cpp +198 -0
- data/ext/cohere_transcribe_native/test/native_abi_reliability_smoke.cpp +186 -0
- data/ext/cohere_transcribe_native/test/native_batch_projection_probe.rb +81 -0
- data/ext/cohere_transcribe_native/test/native_cancellation_smoke.cpp +194 -0
- data/lib/cohere/transcribe/alignment/ATTRIBUTION.md +23 -0
- data/lib/cohere/transcribe/alignment/LICENSE.ctc-forced-aligner +407 -0
- data/lib/cohere/transcribe/alignment/LICENSE.torchaudio +25 -0
- data/lib/cohere/transcribe/alignment/LICENSE.uroman +26 -0
- data/lib/cohere/transcribe/alignment/aligner.rb +476 -0
- data/lib/cohere/transcribe/alignment/ctc.rb +224 -0
- data/lib/cohere/transcribe/alignment/text.rb +237 -0
- data/lib/cohere/transcribe/alignment/uroman_data.rb +4950 -0
- data/lib/cohere/transcribe/api.rb +173 -0
- data/lib/cohere/transcribe/asr/batching.rb +472 -0
- data/lib/cohere/transcribe/asr/failure_policy.rb +112 -0
- data/lib/cohere/transcribe/asr/native.rb +676 -0
- data/lib/cohere/transcribe/audio/ATTRIBUTION.md +8 -0
- data/lib/cohere/transcribe/audio/LICENSE.auditok +21 -0
- data/lib/cohere/transcribe/audio/decoder.rb +315 -0
- data/lib/cohere/transcribe/audio/ffmpeg_native.rb +248 -0
- data/lib/cohere/transcribe/audio/segmentation.rb +260 -0
- data/lib/cohere/transcribe/cli.rb +727 -0
- data/lib/cohere/transcribe/configuration.rb +282 -0
- data/lib/cohere/transcribe/constants.rb +14 -0
- data/lib/cohere/transcribe/dense_converter.rb +548 -0
- data/lib/cohere/transcribe/doctor.rb +576 -0
- data/lib/cohere/transcribe/errors.rb +57 -0
- data/lib/cohere/transcribe/gguf_writer.rb +268 -0
- data/lib/cohere/transcribe/hub.rb +436 -0
- data/lib/cohere/transcribe/input.rb +110 -0
- data/lib/cohere/transcribe/licenses/crispasr.txt +21 -0
- data/lib/cohere/transcribe/loader.rb +128 -0
- data/lib/cohere/transcribe/model_identity.rb +440 -0
- data/lib/cohere/transcribe/output/publication.rb +1118 -0
- data/lib/cohere/transcribe/output/rendering.rb +105 -0
- data/lib/cohere/transcribe/output/timing.rb +86 -0
- data/lib/cohere/transcribe/python_text.rb +70 -0
- data/lib/cohere/transcribe/pytorch_checkpoint.rb +1180 -0
- data/lib/cohere/transcribe/runtime/engine.rb +1676 -0
- data/lib/cohere/transcribe/runtime/model_provider.rb +390 -0
- data/lib/cohere/transcribe/runtime/precision.rb +57 -0
- data/lib/cohere/transcribe/runtime/preparation.rb +215 -0
- data/lib/cohere/transcribe/runtime/resources.rb +165 -0
- data/lib/cohere/transcribe/runtime/word_pipeline.rb +364 -0
- data/lib/cohere/transcribe/safetensors.rb +579 -0
- data/lib/cohere/transcribe/state/checkpoint.rb +224 -0
- data/lib/cohere/transcribe/state/contracts.rb +141 -0
- data/lib/cohere/transcribe/state/io.rb +727 -0
- data/lib/cohere/transcribe/state/locking.rb +211 -0
- data/lib/cohere/transcribe/state/manifest.rb +155 -0
- data/lib/cohere/transcribe/state.rb +7 -0
- data/lib/cohere/transcribe/types.rb +535 -0
- data/lib/cohere/transcribe/vad/ATTRIBUTION.md +14 -0
- data/lib/cohere/transcribe/vad/LICENSE.faster-whisper +21 -0
- data/lib/cohere/transcribe/vad/LICENSE.silero-vad +21 -0
- data/lib/cohere/transcribe/vad/silero.rb +344 -0
- data/lib/cohere/transcribe/vad/silero_vad_v6.onnx +0 -0
- data/lib/cohere/transcribe/vad/timestamps.rb +219 -0
- data/lib/cohere/transcribe/version.rb +7 -0
- data/lib/cohere/transcribe.rb +26 -0
- data/sig/cohere/transcribe.rbs +250 -0
- data/vendor/crispasr/AUTHORS +510 -0
- data/vendor/crispasr/LICENSE +21 -0
- data/vendor/crispasr/UPSTREAM.md +9 -0
- data/vendor/crispasr/VERSION +1 -0
- data/vendor/crispasr/ggml/AUTHORS +335 -0
- data/vendor/crispasr/ggml/CMakeLists.txt +512 -0
- data/vendor/crispasr/ggml/LICENSE +21 -0
- data/vendor/crispasr/ggml/README.md +49 -0
- data/vendor/crispasr/ggml/cmake/FindNCCL.cmake +36 -0
- data/vendor/crispasr/ggml/cmake/GitVars.cmake +22 -0
- data/vendor/crispasr/ggml/cmake/common.cmake +50 -0
- data/vendor/crispasr/ggml/cmake/ggml-config.cmake.in +191 -0
- data/vendor/crispasr/ggml/ggml.pc.in +10 -0
- data/vendor/crispasr/ggml/include/ggml-alloc.h +85 -0
- data/vendor/crispasr/ggml/include/ggml-backend.h +431 -0
- data/vendor/crispasr/ggml/include/ggml-blas.h +25 -0
- data/vendor/crispasr/ggml/include/ggml-cann.h +123 -0
- data/vendor/crispasr/ggml/include/ggml-cpp.h +39 -0
- data/vendor/crispasr/ggml/include/ggml-cpu.h +151 -0
- data/vendor/crispasr/ggml/include/ggml-cuda.h +50 -0
- data/vendor/crispasr/ggml/include/ggml-hexagon.h +19 -0
- data/vendor/crispasr/ggml/include/ggml-metal.h +61 -0
- data/vendor/crispasr/ggml/include/ggml-opencl.h +26 -0
- data/vendor/crispasr/ggml/include/ggml-openvino.h +37 -0
- data/vendor/crispasr/ggml/include/ggml-opt.h +256 -0
- data/vendor/crispasr/ggml/include/ggml-rpc.h +35 -0
- data/vendor/crispasr/ggml/include/ggml-sycl.h +49 -0
- data/vendor/crispasr/ggml/include/ggml-virtgpu.h +14 -0
- data/vendor/crispasr/ggml/include/ggml-vulkan.h +29 -0
- data/vendor/crispasr/ggml/include/ggml-webgpu.h +19 -0
- data/vendor/crispasr/ggml/include/ggml-zdnn.h +17 -0
- data/vendor/crispasr/ggml/include/ggml-zendnn.h +22 -0
- data/vendor/crispasr/ggml/include/ggml.h +2887 -0
- data/vendor/crispasr/ggml/include/gguf.h +204 -0
- data/vendor/crispasr/ggml/src/CMakeLists.txt +493 -0
- data/vendor/crispasr/ggml/src/ggml-alloc.c +1323 -0
- data/vendor/crispasr/ggml/src/ggml-backend-dl.cpp +48 -0
- data/vendor/crispasr/ggml/src/ggml-backend-dl.h +44 -0
- data/vendor/crispasr/ggml/src/ggml-backend-impl.h +275 -0
- data/vendor/crispasr/ggml/src/ggml-backend-meta.cpp +2145 -0
- data/vendor/crispasr/ggml/src/ggml-backend-reg.cpp +586 -0
- data/vendor/crispasr/ggml/src/ggml-backend.cpp +2437 -0
- data/vendor/crispasr/ggml/src/ggml-common.h +1900 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/CMakeLists.txt +718 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.cpp +249 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.h +8 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/common.h +115 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.cpp +2512 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.h +10 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +98 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/quants.c +4244 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/repack.cpp +5156 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/loongarch/quants.c +2158 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/quants.c +2304 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/cpu-feats.cpp +38 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/quants.c +4455 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/repack.cpp +1703 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp +50 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/quants.c +1465 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/wasm/quants.c +1220 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/quants.c +3970 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/repack.cpp +6407 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch-fallback.h +349 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.cpp +154 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.h +16 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/common.h +95 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu-impl.h +539 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.c +3791 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.cpp +703 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/hbm.cpp +55 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/hbm.h +8 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.cpp +939 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.h +90 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1513 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.cpp +4051 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.h +25 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ops.cpp +11662 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ops.h +121 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/quants.c +1288 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/quants.h +103 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/repack.cpp +4836 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/repack.h +245 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/simd-gemm.h +226 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/simd-mappings.h +1329 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.cpp +1025 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.h +13 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +3196 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime_kernels.h +26 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/traits.cpp +36 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/traits.h +38 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.cpp +336 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.h +35 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/vec.cpp +681 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/vec.h +1606 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/CMakeLists.txt +272 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/acc.cu +61 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/acc.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cu +58 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/arange.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/arange.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cu +91 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cu +265 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cuh +19 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cu +534 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cuh +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cu +45 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/common.cuh +1489 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/concat.cu +204 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/concat.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cu +97 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cu +115 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cu +166 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/convert.cu +892 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/convert.cuh +66 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cu +64 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cp-async.cuh +57 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy-utils.cuh +217 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cu +581 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cu +177 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cu +307 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/dequantize.cuh +99 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diag.cu +77 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diag.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cu +40 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-common.cuh +1212 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1860 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cu +57 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cuh +1309 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-vec.cuh +600 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cu +696 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +51 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cu +620 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fill.cu +37 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fill.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cu +273 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cuh +4 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cu +332 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cuh +15 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ggml-cuda.cu +5580 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gla.cu +93 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gla.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cu +274 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cuh +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mean.cu +75 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mean.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mma.cuh +1333 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cu +191 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cuh +908 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cu +164 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cu +372 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cuh +4175 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cu +862 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cuh +14 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cu +1161 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cuh +16 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/norm.cu +756 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/norm.cuh +20 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cu +68 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad.cu +106 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cu +91 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cu +94 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cu +443 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cuh +41 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/reduce_rows.cuh +39 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/roll.cu +67 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/roll.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/rope.cu +665 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/rope.cuh +9 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/scale.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/scale.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cu +330 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set.cu +39 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cu +472 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cu +275 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cu +197 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cu +342 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sum.cu +41 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sum.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cu +43 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cuh +4 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_32.cu +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_32.cu +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq112-dv112.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq128-dv128.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq256-dv256.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq320-dv256.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq40-dv40.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq512-dv512.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq576-dv512.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq64-dv64.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq72-dv72.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq80-dv80.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq96-dv96.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_10.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_11.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_12.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_13.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_14.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_15.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_2.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_3.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_5.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_6.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_7.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_8.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_9.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-nvfp4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q1_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cu +95 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cu +415 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cuh +27 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tri.cu +136 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tri.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cu +47 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/unary.cu +644 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/unary.cuh +116 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cu +293 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vecdotq.cuh +1317 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/cuda.h +28 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/hip.h +306 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/musa.h +148 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cu +199 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-impl.h +783 -0
- data/vendor/crispasr/ggml/src/ggml-metal/CMakeLists.txt +124 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.cpp +457 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.h +52 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.h +41 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.m +778 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.cpp +2117 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.h +299 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.m +2093 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-impl.h +1267 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.cpp +5023 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.h +111 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.cpp +954 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.metal +11756 -0
- data/vendor/crispasr/ggml/src/ggml-opt.cpp +1094 -0
- data/vendor/crispasr/ggml/src/ggml-quants.c +5491 -0
- data/vendor/crispasr/ggml/src/ggml-quants.h +112 -0
- data/vendor/crispasr/ggml/src/ggml-threading.cpp +12 -0
- data/vendor/crispasr/ggml/src/ggml-threading.h +14 -0
- data/vendor/crispasr/ggml/src/ggml.c +7925 -0
- data/vendor/crispasr/ggml/src/ggml.cpp +26 -0
- data/vendor/crispasr/ggml/src/gguf.cpp +1556 -0
- data/vendor/crispasr/src/cohere-arch.h +137 -0
- data/vendor/crispasr/src/cohere.cpp +5642 -0
- data/vendor/crispasr/src/cohere.h +327 -0
- data/vendor/crispasr/src/cohere_batch_planner.h +82 -0
- data/vendor/crispasr/src/cohere_chunking.h +64 -0
- data/vendor/crispasr/src/cohere_decoder_batch_layout.h +60 -0
- data/vendor/crispasr/src/cohere_encoder_padded_layout.h +27 -0
- data/vendor/crispasr/src/cohere_frontend.cpp +189 -0
- data/vendor/crispasr/src/cohere_frontend.h +31 -0
- data/vendor/crispasr/src/cohere_ragged_controller.h +149 -0
- data/vendor/crispasr/src/cohere_token_renderer.h +181 -0
- data/vendor/crispasr/src/core/attention.h +924 -0
- data/vendor/crispasr/src/core/audio_chunking.h +97 -0
- data/vendor/crispasr/src/core/beam_decode.h +486 -0
- data/vendor/crispasr/src/core/cpu_ops.h +135 -0
- data/vendor/crispasr/src/core/gguf_loader.cpp +1021 -0
- data/vendor/crispasr/src/core/gguf_loader.h +216 -0
- data/vendor/crispasr/src/core/gpu_backend_pref.h +119 -0
- data/vendor/crispasr/src/core/mel.cpp +519 -0
- data/vendor/crispasr/src/core/mel.h +265 -0
- data/vendor/crispasr/src/core/ngram_loop_fix.h +173 -0
- data/vendor/crispasr/src/core/repetition_loop_guard.h +54 -0
- data/vendor/crispasr/src/crispasr_imatrix.cpp +255 -0
- data/vendor/crispasr/src/crispasr_imatrix.h +38 -0
- metadata +596 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require_relative "constants"
|
|
5
|
+
|
|
6
|
+
module Cohere
|
|
7
|
+
module Transcribe
|
|
8
|
+
ResolvedModelIdentity = Data.define(
|
|
9
|
+
:model_id,
|
|
10
|
+
:model_revision,
|
|
11
|
+
:model_format,
|
|
12
|
+
:quantization_config,
|
|
13
|
+
:adapter_id,
|
|
14
|
+
:adapter_revision
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
module ModelIdentity
|
|
18
|
+
module_function
|
|
19
|
+
|
|
20
|
+
MODEL_WEIGHT_FILES = %w[
|
|
21
|
+
model.safetensors model.safetensors.index.json
|
|
22
|
+
pytorch_model.bin pytorch_model.bin.index.json
|
|
23
|
+
].freeze
|
|
24
|
+
ADAPTER_WEIGHT_FILES = %w[adapter_model.safetensors adapter_model.bin].freeze
|
|
25
|
+
|
|
26
|
+
def default_model_revision(model_id, revision)
|
|
27
|
+
revision || (model_id == DEFAULT_ASR_MODEL_ID ? DEFAULT_ASR_MODEL_REVISION : nil)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def packaged_default_model?(model_id, revision)
|
|
31
|
+
model_id == DEFAULT_ASR_MODEL_ID && revision == DEFAULT_ASR_MODEL_REVISION
|
|
32
|
+
end
|
|
33
|
+
private_class_method :packaged_default_model?
|
|
34
|
+
|
|
35
|
+
def resolve_local_directory(reference, description: "Model")
|
|
36
|
+
raise TypeError, "#{description} must be a string" unless reference.is_a?(String)
|
|
37
|
+
|
|
38
|
+
source_path = Pathname(reference)
|
|
39
|
+
path = begin
|
|
40
|
+
expand_user_path(source_path)
|
|
41
|
+
rescue ArgumentError, SystemCallError => e
|
|
42
|
+
raise ArgumentError,
|
|
43
|
+
"Cannot resolve #{description.downcase} path #{reference.inspect}: #{e.message}"
|
|
44
|
+
end
|
|
45
|
+
return path.realpath.to_s if path.directory?
|
|
46
|
+
if path.exist? || path.symlink?
|
|
47
|
+
raise ArgumentError,
|
|
48
|
+
"#{description} path #{reference.inspect} is not a directory"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
explicit_reference = reference.start_with?("./", "../", "~") ||
|
|
52
|
+
[".", "..", "~"].include?(reference) ||
|
|
53
|
+
reference.count("/") > 1
|
|
54
|
+
explicit = source_path.absolute? || explicit_reference
|
|
55
|
+
raise ArgumentError, "#{description} directory #{reference.inspect} does not exist" if explicit
|
|
56
|
+
|
|
57
|
+
nil
|
|
58
|
+
rescue SystemCallError => e
|
|
59
|
+
raise ArgumentError, "Cannot resolve #{description.downcase} path #{reference.inspect}: #{e.message}"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Path.expanduser() expands only the leading home-directory component;
|
|
63
|
+
# unlike Pathname#expand_path, it does not lexically erase a missing
|
|
64
|
+
# component followed by `..` before the filesystem probe.
|
|
65
|
+
def expand_user_path(path)
|
|
66
|
+
reference = path.to_s
|
|
67
|
+
# pathlib drops relative `.` components while constructing Path, before
|
|
68
|
+
# expanduser() examines the first component (so `./~` means the home
|
|
69
|
+
# directory). Preserve every `..` component for the later OS probe.
|
|
70
|
+
normalized_reference = reference.sub(%r{\A(?:\./+)+}, "")
|
|
71
|
+
return path unless normalized_reference.start_with?("~")
|
|
72
|
+
|
|
73
|
+
home_reference, separator, remainder = normalized_reference.partition("/")
|
|
74
|
+
home = Pathname(File.expand_path(home_reference))
|
|
75
|
+
separator.empty? ? home : home.join(remainder)
|
|
76
|
+
end
|
|
77
|
+
private_class_method :expand_user_path
|
|
78
|
+
|
|
79
|
+
def classify_model_config(config, reference)
|
|
80
|
+
unless config["model_type"] == "cohere_asr"
|
|
81
|
+
raise ArgumentError,
|
|
82
|
+
"#{reference} uses model_type=#{python_value_repr(config["model_type"])}; " \
|
|
83
|
+
"expected a native Transformers Cohere ASR checkpoint"
|
|
84
|
+
end
|
|
85
|
+
architectures = config["architectures"]
|
|
86
|
+
if python_truthy?(architectures) && !declares_cohere_asr_architecture?(architectures)
|
|
87
|
+
raise ArgumentError, "#{reference} does not declare CohereAsrForConditionalGeneration"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
quantization = config["quantization_config"]
|
|
91
|
+
return [:dense, nil] if quantization.nil?
|
|
92
|
+
raise ArgumentError, "#{reference} has an invalid quantization_config" unless quantization.is_a?(Hash)
|
|
93
|
+
|
|
94
|
+
method = python_lower(python_string(quantization.fetch("quant_method", "")))
|
|
95
|
+
four_bit = quantization.fetch("load_in_4bit", quantization.fetch("_load_in_4bit", false))
|
|
96
|
+
eight_bit = quantization.fetch("load_in_8bit", quantization.fetch("_load_in_8bit", false))
|
|
97
|
+
unless [four_bit, eight_bit].all? { |value| [true, false].include?(value) }
|
|
98
|
+
raise ArgumentError,
|
|
99
|
+
"#{reference} has an invalid quantization_config: " \
|
|
100
|
+
"bitsandbytes load flags must be boolean"
|
|
101
|
+
end
|
|
102
|
+
unless method == "bitsandbytes" && four_bit != eight_bit
|
|
103
|
+
rendered_method = method.empty? ? "unknown" : method
|
|
104
|
+
raise ArgumentError,
|
|
105
|
+
"#{reference} uses unsupported saved quantization configuration " \
|
|
106
|
+
"#{python_string_repr(rendered_method)}"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
[four_bit ? :"bitsandbytes-int4" : :"bitsandbytes-int8", quantization.dup.freeze]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def resolve(model_id, model_revision = nil, adapter_id = nil, adapter_revision = nil,
|
|
113
|
+
hub: Hub.new, verify_weight_artifacts: true)
|
|
114
|
+
raise ArgumentError, "adapter_revision requires an adapter_id" if adapter_id.nil? && adapter_revision
|
|
115
|
+
|
|
116
|
+
resolved_model_id, resolved_model_revision, model_dir = resolve_reference(
|
|
117
|
+
model_id,
|
|
118
|
+
model_revision,
|
|
119
|
+
description: "Model",
|
|
120
|
+
metadata: "config.json",
|
|
121
|
+
hub: hub,
|
|
122
|
+
default_revision: default_model_revision(model_id, model_revision)
|
|
123
|
+
)
|
|
124
|
+
if packaged_default_model?(resolved_model_id, resolved_model_revision)
|
|
125
|
+
format = :dense
|
|
126
|
+
quantization = nil
|
|
127
|
+
else
|
|
128
|
+
config_path = if model_dir
|
|
129
|
+
Pathname(model_dir).join("config.json")
|
|
130
|
+
else
|
|
131
|
+
hub.download(
|
|
132
|
+
resolved_model_id, "config.json", revision: resolved_model_revision
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
config = read_json_object(config_path)
|
|
136
|
+
reference = reference(resolved_model_id, resolved_model_revision)
|
|
137
|
+
format, quantization = classify_model_config(config, reference)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
resolved_adapter_id = nil
|
|
141
|
+
resolved_adapter_revision = nil
|
|
142
|
+
if adapter_id
|
|
143
|
+
raise ArgumentError, "PEFT adapters are supported only with dense base models" unless format == :dense
|
|
144
|
+
|
|
145
|
+
resolved_adapter_id, resolved_adapter_revision, adapter_dir = resolve_reference(
|
|
146
|
+
adapter_id,
|
|
147
|
+
adapter_revision,
|
|
148
|
+
description: "Adapter",
|
|
149
|
+
metadata: "adapter_config.json",
|
|
150
|
+
hub: hub,
|
|
151
|
+
default_revision: adapter_revision
|
|
152
|
+
)
|
|
153
|
+
adapter_path = if adapter_dir
|
|
154
|
+
Pathname(adapter_dir).join("adapter_config.json")
|
|
155
|
+
else
|
|
156
|
+
hub.download(
|
|
157
|
+
resolved_adapter_id, "adapter_config.json", revision: resolved_adapter_revision
|
|
158
|
+
)
|
|
159
|
+
end
|
|
160
|
+
adapter_config = read_json_object(adapter_path)
|
|
161
|
+
validate_adapter_config!(
|
|
162
|
+
adapter_config,
|
|
163
|
+
resolved_model_id,
|
|
164
|
+
resolved_model_revision,
|
|
165
|
+
adapter_id: resolved_adapter_id,
|
|
166
|
+
adapter_revision: resolved_adapter_revision,
|
|
167
|
+
hub: hub
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
identity = ResolvedModelIdentity.new(
|
|
172
|
+
model_id: resolved_model_id,
|
|
173
|
+
model_revision: resolved_model_revision,
|
|
174
|
+
model_format: format,
|
|
175
|
+
quantization_config: quantization,
|
|
176
|
+
adapter_id: resolved_adapter_id,
|
|
177
|
+
adapter_revision: resolved_adapter_revision
|
|
178
|
+
)
|
|
179
|
+
verify_model_weight_artifacts(identity, hub: hub) if verify_weight_artifacts
|
|
180
|
+
identity
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Identity resolution is also used while planning runs that may be fully
|
|
184
|
+
# satisfied by checkpoints. Keep weight discovery as a separate operation
|
|
185
|
+
# so those runs do not require inference artifacts they will never load.
|
|
186
|
+
def verify_model_weight_artifacts(identity, hub: Hub.new)
|
|
187
|
+
unless packaged_default_model?(identity.model_id, identity.model_revision)
|
|
188
|
+
verify_weight_artifacts!(
|
|
189
|
+
identity.model_id,
|
|
190
|
+
identity.model_revision,
|
|
191
|
+
MODEL_WEIGHT_FILES,
|
|
192
|
+
"Transformers model weights",
|
|
193
|
+
hub: hub
|
|
194
|
+
)
|
|
195
|
+
end
|
|
196
|
+
return unless identity.adapter_id
|
|
197
|
+
|
|
198
|
+
verify_weight_artifacts!(
|
|
199
|
+
identity.adapter_id,
|
|
200
|
+
identity.adapter_revision,
|
|
201
|
+
ADAPTER_WEIGHT_FILES,
|
|
202
|
+
"PEFT adapter weights",
|
|
203
|
+
hub: hub
|
|
204
|
+
)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def reference(model_id, revision)
|
|
208
|
+
revision ? "#{model_id}@#{revision}" : model_id
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def read_json_object(path)
|
|
212
|
+
path = Pathname(path)
|
|
213
|
+
raise ArgumentError, "Local artifact #{path} is missing or is not a file" unless path.file?
|
|
214
|
+
|
|
215
|
+
payload = JSON.parse(path.read(encoding: "UTF-8"))
|
|
216
|
+
raise ArgumentError, "#{path} is not a JSON object" unless payload.is_a?(Hash)
|
|
217
|
+
|
|
218
|
+
payload
|
|
219
|
+
rescue SystemCallError, JSON::ParserError, EncodingError => e
|
|
220
|
+
raise ArgumentError, "Cannot read JSON object from #{path}: #{e.message}"
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# JSON config data reaches the Python reference implementation as native
|
|
224
|
+
# Python values. Preserve its truthiness and container-membership behavior
|
|
225
|
+
# here, including TypeError for truthy scalar architecture declarations.
|
|
226
|
+
def python_truthy?(value)
|
|
227
|
+
return false if value.nil? || value == false
|
|
228
|
+
return !value.zero? if value.is_a?(Numeric)
|
|
229
|
+
return !value.empty? if value.is_a?(String) || value.is_a?(Array) || value.is_a?(Hash)
|
|
230
|
+
|
|
231
|
+
true
|
|
232
|
+
end
|
|
233
|
+
private_class_method :python_truthy?
|
|
234
|
+
|
|
235
|
+
def declares_cohere_asr_architecture?(architectures)
|
|
236
|
+
expected = "CohereAsrForConditionalGeneration"
|
|
237
|
+
case architectures
|
|
238
|
+
when String
|
|
239
|
+
architectures.include?(expected)
|
|
240
|
+
when Array
|
|
241
|
+
architectures.include?(expected)
|
|
242
|
+
when Hash
|
|
243
|
+
architectures.key?(expected)
|
|
244
|
+
else
|
|
245
|
+
type = case architectures
|
|
246
|
+
when true, false then "bool"
|
|
247
|
+
when Integer then "int"
|
|
248
|
+
when Float then "float"
|
|
249
|
+
else architectures.class.name
|
|
250
|
+
end
|
|
251
|
+
raise TypeError, "argument of type '#{type}' is not iterable"
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
private_class_method :declares_cohere_asr_architecture?
|
|
255
|
+
|
|
256
|
+
# Python's classifier applies str(...).lower() to quant_method. JSON's
|
|
257
|
+
# null/boolean/container spellings differ from Ruby's #to_s, so reproduce
|
|
258
|
+
# them before classifying and rendering the public diagnostic.
|
|
259
|
+
def python_string(value)
|
|
260
|
+
case value
|
|
261
|
+
when nil then "None"
|
|
262
|
+
when true then "True"
|
|
263
|
+
when false then "False"
|
|
264
|
+
when String then value
|
|
265
|
+
when Float then python_float_string(value)
|
|
266
|
+
when Array then "[#{value.map { |item| python_value_repr(item) }.join(", ")}]"
|
|
267
|
+
when Hash
|
|
268
|
+
entries = value.map do |key, item|
|
|
269
|
+
"#{python_value_repr(key)}: #{python_value_repr(item)}"
|
|
270
|
+
end
|
|
271
|
+
"{#{entries.join(", ")}}"
|
|
272
|
+
else value.to_s
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
private_class_method :python_string
|
|
276
|
+
|
|
277
|
+
def python_float_string(value)
|
|
278
|
+
return "nan" if value.nan?
|
|
279
|
+
return value.negative? ? "-inf" : "inf" if value.infinite?
|
|
280
|
+
|
|
281
|
+
rendered = value.to_s
|
|
282
|
+
match = /\A(-?)(\d)(?:\.(\d+))?e([+-])(\d+)\z/.match(rendered)
|
|
283
|
+
return rendered unless match
|
|
284
|
+
|
|
285
|
+
exponent = match[5].to_i * (match[4] == "-" ? -1 : 1)
|
|
286
|
+
return rendered.sub(/\.0(?=e[+-]\d+\z)/, "") unless exponent.between?(-4, 15)
|
|
287
|
+
|
|
288
|
+
digits = match[2] + match[3].to_s
|
|
289
|
+
decimal_index = exponent + 1
|
|
290
|
+
body = if decimal_index <= 0
|
|
291
|
+
"0.#{"0" * -decimal_index}#{digits}"
|
|
292
|
+
elsif decimal_index >= digits.length
|
|
293
|
+
"#{digits}#{"0" * (decimal_index - digits.length)}.0"
|
|
294
|
+
else
|
|
295
|
+
"#{digits[0, decimal_index]}.#{digits[decimal_index..]}"
|
|
296
|
+
end
|
|
297
|
+
"#{match[1]}#{body}"
|
|
298
|
+
end
|
|
299
|
+
private_class_method :python_float_string
|
|
300
|
+
|
|
301
|
+
def python_lower(value)
|
|
302
|
+
characters = value.each_char.to_a
|
|
303
|
+
characters.each_with_index.map do |character, index|
|
|
304
|
+
if character == "Σ" && python_final_sigma?(characters, index)
|
|
305
|
+
"ς"
|
|
306
|
+
else
|
|
307
|
+
character.downcase
|
|
308
|
+
end
|
|
309
|
+
end.join
|
|
310
|
+
end
|
|
311
|
+
private_class_method :python_lower
|
|
312
|
+
|
|
313
|
+
def python_final_sigma?(characters, index)
|
|
314
|
+
before = characters[0...index].rfind { |character| !character.match?(/\p{Case_Ignorable}/u) }
|
|
315
|
+
return false unless before&.match?(/\p{Cased}/u)
|
|
316
|
+
|
|
317
|
+
after = characters[(index + 1)..].find { |character| !character.match?(/\p{Case_Ignorable}/u) }
|
|
318
|
+
!after&.match?(/\p{Cased}/u)
|
|
319
|
+
end
|
|
320
|
+
private_class_method :python_final_sigma?
|
|
321
|
+
|
|
322
|
+
def python_value_repr(value)
|
|
323
|
+
case value
|
|
324
|
+
when nil then "None"
|
|
325
|
+
when true then "True"
|
|
326
|
+
when false then "False"
|
|
327
|
+
when String then python_string_repr(value)
|
|
328
|
+
else python_string(value)
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
private_class_method :python_value_repr
|
|
332
|
+
|
|
333
|
+
def python_string_repr(value)
|
|
334
|
+
quote = value.include?("'") && !value.include?('"') ? '"' : "'"
|
|
335
|
+
escaped = value.each_char.map do |character|
|
|
336
|
+
case character
|
|
337
|
+
when "\\" then "\\\\"
|
|
338
|
+
when quote then "\\#{quote}"
|
|
339
|
+
when "\t" then "\\t"
|
|
340
|
+
when "\n" then "\\n"
|
|
341
|
+
when "\r" then "\\r"
|
|
342
|
+
else
|
|
343
|
+
codepoint = character.ord
|
|
344
|
+
non_printing = character != " " && character.match?(/[\p{C}\p{Z}]/u)
|
|
345
|
+
if codepoint < 0x20 || codepoint == 0x7f || non_printing
|
|
346
|
+
case codepoint
|
|
347
|
+
when 0..0xff then format("\\x%02x", codepoint)
|
|
348
|
+
when 0x100..0xffff then format("\\u%04x", codepoint)
|
|
349
|
+
else format("\\U%08x", codepoint)
|
|
350
|
+
end
|
|
351
|
+
else
|
|
352
|
+
character
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
end.join
|
|
356
|
+
"#{quote}#{escaped}#{quote}"
|
|
357
|
+
end
|
|
358
|
+
private_class_method :python_string_repr
|
|
359
|
+
|
|
360
|
+
def resolve_reference(id, revision, description:, metadata:, hub:, default_revision:)
|
|
361
|
+
raise TypeError, "#{description} must be a string" unless id.is_a?(String)
|
|
362
|
+
raise ArgumentError, "#{description} must not be empty" if id.strip.empty?
|
|
363
|
+
|
|
364
|
+
local = resolve_local_directory(id, description: description)
|
|
365
|
+
if local
|
|
366
|
+
raise ArgumentError, "A #{description.downcase} revision cannot be used with a local directory" if revision
|
|
367
|
+
|
|
368
|
+
return [local, nil, local]
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
commit = hub.resolve_revision(id, default_revision, filename: metadata)
|
|
372
|
+
[id, commit, nil]
|
|
373
|
+
end
|
|
374
|
+
private_class_method :resolve_reference
|
|
375
|
+
|
|
376
|
+
def verify_weight_artifacts!(id, revision, candidates, description, hub:)
|
|
377
|
+
if revision
|
|
378
|
+
verify_remote_weights!(hub, id, revision, candidates, description)
|
|
379
|
+
else
|
|
380
|
+
verify_local_weights!(id, candidates, description)
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
private_class_method :verify_weight_artifacts!
|
|
384
|
+
|
|
385
|
+
def verify_local_weights!(directory, candidates, description)
|
|
386
|
+
directory = Pathname(directory)
|
|
387
|
+
return if candidates.any? { |name| directory.join(name).file? }
|
|
388
|
+
|
|
389
|
+
expected = candidates.sort.join(", ")
|
|
390
|
+
raise ArgumentError,
|
|
391
|
+
"Local directory #{directory.to_s.inspect} does not contain supported #{description}; " \
|
|
392
|
+
"expected one of: #{expected}"
|
|
393
|
+
end
|
|
394
|
+
private_class_method :verify_local_weights!
|
|
395
|
+
|
|
396
|
+
def verify_remote_weights!(hub, repo_id, revision, candidates, description)
|
|
397
|
+
return if candidates.any? { |name| hub.cached_file(repo_id, name, revision: revision) }
|
|
398
|
+
return if hub.list_files(repo_id, revision: revision).intersect?(candidates)
|
|
399
|
+
|
|
400
|
+
expected = candidates.sort.join(", ")
|
|
401
|
+
raise ArgumentError,
|
|
402
|
+
"#{repo_id}@#{revision} does not contain supported #{description}; expected one of: #{expected}"
|
|
403
|
+
end
|
|
404
|
+
private_class_method :verify_remote_weights!
|
|
405
|
+
|
|
406
|
+
def validate_adapter_config!(config, model_id, model_revision, adapter_id:, adapter_revision:, hub:)
|
|
407
|
+
raise ArgumentError, "Adapter peft_type must be LORA" unless config["peft_type"].to_s.upcase == "LORA"
|
|
408
|
+
raise ArgumentError, "Adapter task_type must be SEQ_2_SEQ_LM" unless config["task_type"].to_s.upcase == "SEQ_2_SEQ_LM"
|
|
409
|
+
|
|
410
|
+
# A local base has no stable Hub identity against which a training-time
|
|
411
|
+
# repository string can be compared. Remote bases do, so require the
|
|
412
|
+
# adapter to name that exact repository and compare immutable commits.
|
|
413
|
+
return unless model_revision
|
|
414
|
+
|
|
415
|
+
declared_base = config["base_model_name_or_path"]
|
|
416
|
+
adapter_reference = reference(adapter_id, adapter_revision)
|
|
417
|
+
if declared_base != model_id
|
|
418
|
+
raise ArgumentError,
|
|
419
|
+
"Adapter #{adapter_reference} requires base model " \
|
|
420
|
+
"#{declared_base.inspect}, not #{model_id.inspect}"
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
declared_revision = config["revision"]
|
|
424
|
+
return unless declared_revision
|
|
425
|
+
|
|
426
|
+
expected_revision = hub.resolve_revision(
|
|
427
|
+
model_id,
|
|
428
|
+
declared_revision.to_s,
|
|
429
|
+
filename: "config.json"
|
|
430
|
+
)
|
|
431
|
+
return if expected_revision == model_revision
|
|
432
|
+
|
|
433
|
+
raise ArgumentError,
|
|
434
|
+
"Adapter #{adapter_reference} requires base revision " \
|
|
435
|
+
"#{expected_revision}, not #{model_revision}"
|
|
436
|
+
end
|
|
437
|
+
private_class_method :validate_adapter_config!
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
end
|