Skip to content
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

[Prompt lookup] #1245

Merged
merged 42 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7d52af2
init
iefode Nov 21, 2024
f38cc19
Working Lookup
iefode Nov 22, 2024
1b2fdec
Remove extra
iefode Nov 22, 2024
354f612
remove etxra
iefode Nov 25, 2024
9cef97d
Merge remote-tracking branch 'upstream/master' into prompt_lookup
iefode Nov 25, 2024
37c56d7
Ngram
iefode Dec 4, 2024
d0c23a2
Merge remote-tracking branch 'upstream/master' into prompt_lookup
iefode Dec 4, 2024
3c42bfd
debug
iefode Dec 4, 2024
86e23b9
tmp
iefode Dec 4, 2024
ff9e08e
remove extra check from ci validation
iefode Dec 4, 2024
59bd0b3
Merge branch 'master' into prompt_lookup
iefode Dec 5, 2024
bdf10dc
Upgrade runner
iefode Dec 5, 2024
091f1be
Merge branch 'prompt_lookup' of github.com:iefode/openvino.genai into…
iefode Dec 5, 2024
1f9fc5d
Merge branch 'master' into prompt_lookup
iefode Dec 5, 2024
66d4c34
Apply review
iefode Dec 6, 2024
c306f8f
Merge branch 'prompt_lookup' of github.com:iefode/openvino.genai into…
iefode Dec 6, 2024
b02887d
ci
iefode Dec 6, 2024
bf79557
enable prompt enable in python
iefode Dec 10, 2024
33725cf
Merge remote-tracking branch 'upstream/master' into prompt_lookup
iefode Dec 10, 2024
8a086a8
try
iefode Dec 10, 2024
fb701c0
test
iefode Dec 10, 2024
f1477f5
check
iefode Dec 10, 2024
460e28f
test
iefode Dec 10, 2024
61b7be3
Merge remote-tracking branch 'upstream/master' into prompt_lookup
iefode Dec 11, 2024
5efb939
CI Prompt lookup
iefode Dec 11, 2024
42269e5
Update causal_lm_cpp.yml
iefode Dec 11, 2024
2cdef4d
Update causal_lm_cpp.yml
iefode Dec 12, 2024
46a7d0b
Readme
iefode Dec 13, 2024
62ec01f
Merge remote-tracking branch 'upstream/master' into prompt_lookup
iefode Dec 13, 2024
adfd630
Merge branch 'prompt_lookup' of github.com:iefode/openvino.genai into…
iefode Dec 13, 2024
87e5f7c
review
iefode Dec 16, 2024
d3e24ed
Deprecation
iefode Dec 16, 2024
0e3c0ee
remove
iefode Dec 16, 2024
7d9f7d9
Stubs
iefode Dec 16, 2024
aa3c870
Merge branch 'master' into prompt_lookup
iefode Dec 16, 2024
9f87e89
Merge branch 'master' into prompt_lookup
iefode Dec 16, 2024
6ecd023
..
iefode Dec 16, 2024
f4bb74b
stubs
iefode Dec 16, 2024
a1ba5be
Merge branch 'prompt_lookup' of github.com:iefode/openvino.genai into…
iefode Dec 16, 2024
b4fa210
Merge branch 'master' into prompt_lookup
iefode Dec 17, 2024
1c51000
Merge branch 'master' into prompt_lookup
iefode Dec 17, 2024
2f02787
Merge branch 'master' into prompt_lookup
ilya-lavrenov Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 8 additions & 23 deletions .github/workflows/causal_lm_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ jobs:
python -m pip install ./thirdparty/openvino_tokenizers/[transformers] --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
python -m pip install -r ./samples/requirements.txt
optimum-cli export openvino --trust-remote-code --weight-format fp16 --model TinyLlama/TinyLlama-1.1B-Chat-v1.0 TinyLlama-1.1B-Chat-v1.0
optimum-cli export openvino --trust-remote-code --weight-format fp16 --model Qwen/Qwen-7B-Chat Qwen-7B-Chat --task text-generation-with-past
- name: run and compare
run: |
source ./ov/setupvars.sh
Expand All @@ -505,36 +504,22 @@ jobs:

./build/samples/cpp/prompt_lookup_decoding_lm/prompt_lookup_decoding_lm ./TinyLlama-1.1B-Chat-v1.0/ "$(<prompt.txt)" > predictions_prompt_lookup.txt
./build/samples/cpp/text_generation/greedy_causal_lm ./TinyLlama-1.1B-Chat-v1.0/ "$(<prompt.txt)" > predictions_greedy.txt
python ./samples/python/prompt_lookup_decoding_lm/prompt_lookup_decoding_lm.py ./TinyLlama-1.1B-Chat-v1.0/ "$(<prompt.txt)" > predictions_py.txt
python -c "
with open('predictions_greedy.txt', 'r') as f:
predicted_greedy = f.readline()
with open('predictions_prompt_lookup.txt', 'r') as f:
predicted_prompt_lookup = f.readline()
with open('predictions_py.txt', 'r') as f:
predicted_prompt_lookup_py = f.readline()
assert predicted_greedy == predicted_prompt_lookup
assert predicted_greedy == predicted_prompt_lookup_py
assert predicted_prompt_lookup == predicted_prompt_lookup_py
"
echo "Prompt lookup" passed
- name: run and compare (model with seq_length_axis = 1)
run: |
source ./ov/setupvars.sh

echo 'Code:```python
def add(a, b):
return a + b
```
Question: Can you please add 2 and 3
A:' > ./prompt.txt

./build/samples/cpp/prompt_lookup_decoding_lm/prompt_lookup_decoding_lm ./Qwen-7B-Chat/ "$(<prompt.txt)" > predictions_prompt_lookup.txt
./build/samples/cpp/text_generation/greedy_causal_lm ./Qwen-7B-Chat/ "$(<prompt.txt)" > predictions_greedy.txt
python -c "
with open('predictions_greedy.txt', 'r') as f:
predicted_greedy = f.readline()
with open('predictions_prompt_lookup.txt', 'r') as f:
predicted_prompt_lookup = f.readline()
assert predicted_greedy == predicted_prompt_lookup
"
echo "Prompt lookup" passed

env:
PYTHONPATH: "./build/:$PYTHONPATH"
LD_LIBRARY_PATH: "./build/openvino_genai/:$LD_LIBRARY_PATH"
cpp-Phi-1_5:
runs-on: ubuntu-20.04-16-cores
defaults:
Expand Down
21 changes: 7 additions & 14 deletions samples/cpp/prompt_lookup_decoding_lm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
# Copyright (C) 2023-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

find_package(OpenVINO REQUIRED COMPONENTS Runtime Threading)

find_package(OpenVINOGenAI REQUIRED
PATHS
"${CMAKE_BINARY_DIR}" # Reuse the package from the build.
${OpenVINO_DIR} # GenAI may be installed alogside OpenVINO.
NO_CMAKE_FIND_ROOT_PATH
)

add_executable(prompt_lookup_decoding_lm prompt_lookup_decoding_lm.cpp)
target_link_libraries(prompt_lookup_decoding_lm PRIVATE openvino::runtime openvino::threading)
set_target_properties(prompt_lookup_decoding_lm PROPERTIES
COMPILE_PDB_NAME prompt_lookup_decoding_lm
set(TARGET_NAME prompt_lookup_decoding_lm)
add_executable(${TARGET_NAME} ${TARGET_NAME}.cpp)
target_link_libraries(${TARGET_NAME} PRIVATE openvino::genai)

set_target_properties(${TARGET_NAME} PROPERTIES
COMPILE_PDB_NAME ${TARGET_NAME}
# Ensure out of box LC_RPATH on macOS with SIP
INSTALL_RPATH_USE_LINK_PATH ON)
target_compile_features(prompt_lookup_decoding_lm PRIVATE cxx_std_17)

get_target_property(genai_imported openvino::genai IMPORTED_LOCATION)
set(OPENVINO_TOKENIZERS_PATH $<IF:$<BOOL:${genai_imported}>,${genai_imported},$<TARGET_FILE_DIR:openvino::genai>>)
set(OPENVINO_TOKENIZERS_FILENAME "${CMAKE_SHARED_LIBRARY_PREFIX}openvino_tokenizers${CMAKE_SHARED_LIBRARY_SUFFIX}")
target_compile_definitions(prompt_lookup_decoding_lm PRIVATE
OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}/${OPENVINO_TOKENIZERS_FILENAME}")

install(TARGETS prompt_lookup_decoding_lm
install(TARGETS ${TARGET_NAME}
RUNTIME DESTINATION samples_bin/
COMPONENT samples_bin
EXCLUDE_FROM_ALL)
Loading
Loading