forked from ggerganov/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ggerganov:master' into script
- Loading branch information
Showing
38 changed files
with
5,755 additions
and
4,921 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
torch>=2.0.0 | ||
torch>=2.1.1 | ||
transformers>=4.32.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
# | ||
# Few-shot translation example. | ||
# Requires a base model (i.e. no fine-tuned or instruct models). | ||
# | ||
# Usage: | ||
# | ||
# cd llama.cpp | ||
# make -j | ||
# | ||
# ./examples/base-translate.sh <model-base> "<text>" [extra-main-args] | ||
# | ||
|
||
if [ $# -lt 2 ]; then | ||
echo "Usage: ./base-translate.sh <model-base> \"<text>\" [extra-main-args]" | ||
exit 1 | ||
fi | ||
|
||
eargs="" | ||
if [ $# -gt 2 ]; then | ||
eargs="${@:3}" | ||
fi | ||
|
||
ftmp="__llama.cpp_example_tmp__.txt" | ||
trap "rm -f $ftmp" EXIT | ||
|
||
echo "Translate from English to French: | ||
=== | ||
sea otter, peppermint, plush girafe: | ||
sea otter => loutre de mer | ||
peppermint => menthe poivrée | ||
plush girafe => girafe peluche | ||
=== | ||
violin | ||
violin => violon | ||
=== | ||
phone, computer, mouse, keyboard: | ||
phone => téléphone | ||
computer => ordinateur | ||
mouse => souris | ||
keyboard => clavier | ||
=== | ||
" > $ftmp | ||
|
||
echo "$2 | ||
" >> $ftmp | ||
|
||
model=$1 | ||
|
||
# generate the most likely continuation until the string "===" is found | ||
./main -m $model -f $ftmp -n 64 --temp 0 --repeat-penalty 1.0 --no-penalize-nl -r "===" $eargs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
examples/llama.swiftui/llama.swiftui/UI/LoadCustomButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import SwiftUI | ||
import UniformTypeIdentifiers | ||
|
||
struct LoadCustomButton: View { | ||
@ObservedObject private var llamaState: LlamaState | ||
@State private var showFileImporter = false | ||
|
||
init(llamaState: LlamaState) { | ||
self.llamaState = llamaState | ||
} | ||
|
||
var body: some View { | ||
VStack { | ||
Button(action: { | ||
showFileImporter = true | ||
}) { | ||
Text("Load Custom Model") | ||
} | ||
} | ||
.fileImporter( | ||
isPresented: $showFileImporter, | ||
allowedContentTypes: [UTType(filenameExtension: "gguf", conformingTo: .data)!], | ||
allowsMultipleSelection: false | ||
) { result in | ||
switch result { | ||
case .success(let files): | ||
files.forEach { file in | ||
let gotAccess = file.startAccessingSecurityScopedResource() | ||
if !gotAccess { return } | ||
|
||
do { | ||
try llamaState.loadModel(modelUrl: file.absoluteURL) | ||
} catch let err { | ||
print("Error: \(err.localizedDescription)") | ||
} | ||
|
||
file.stopAccessingSecurityScopedResource() | ||
} | ||
case .failure(let error): | ||
print(error) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.