Download tests/test_adapter.py from khoicrtp/test_model: direct link, hf CLI and curl.
- Browser
- Download file 947 Bytes
-
https://huggingface.co/khoicrtp/test_model/resolve/main/tests/test_adapter.py
- Command line
-
hf download hf://khoicrtp/test_model/tests/test_adapter.py
-
curl -L -o test_adapter.py https://huggingface.co/khoicrtp/test_model/resolve/main/tests/test_adapter.py
947 Bytes
| import torch | |
| from dataclasses import asdict | |
| import pytest | |
| import sys | |
| def test_config_identical(model_size, lit_llama): | |
| import lit_llama.adapter as llama_adapter | |
| import lit_llama.model as llama | |
| from lit_llama.utils import EmptyInitOnDevice | |
| llama_config = asdict(llama.LLaMAConfig.from_name(model_size)) | |
| adapter_config = asdict(llama_adapter.LLaMAConfig.from_name(model_size)) | |
| del adapter_config["adapter_prompt_length"] | |
| del adapter_config["adapter_start_layer"] | |
| assert adapter_config == llama_config | |
| with EmptyInitOnDevice(): | |
| llama_model = llama.LLaMA.from_name(model_size) | |
| adapter_model = llama_adapter.LLaMA.from_name(model_size) | |
| assert llama_model.lm_head.weight.shape == adapter_model.lm_head.weight.shape | |