Skip to content

Commit

Permalink
compare to official llama2
Browse files Browse the repository at this point in the history
  • Loading branch information
dfalbel committed Aug 30, 2023
1 parent 0e87b58 commit ee05745
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/testthat/test-llama.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
test_that("Can create a llama model", {
skip_on_ci() # this is too big for the github runners.
model <- llama_from_pretrained("huggyllama/llama-7b")
model <- llama_from_pretrained("meta-llama/Llama-2-7b-chat-hf")
model$to(dtype=torch_float32())
model$eval()
with_no_grad({
pred <- model(torch_ones(1, 3, dtype="long") + 1L)
})

out <- pred[1, 1, 1:5]
reference <- c(-12.7782, -28.6373, 0.9082, -6.1501, -4.3769)
expect_equal(as.numeric(out), reference, tolerance = 1e-5)

reference <- c(0.2226, 0.0299, 0.2729, -0.7919, 1.6164)
expect_equal(as.numeric(out), reference, tolerance = 1e-4)
})

0 comments on commit ee05745

Please sign in to comment.