llmcomp 1.2.3__tar.gz → 1.2.4__tar.gz

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.
Files changed (44) hide show
  1. {llmcomp-1.2.3 → llmcomp-1.2.4}/PKG-INFO +6 -5
  2. {llmcomp-1.2.3 → llmcomp-1.2.4}/README.md +5 -4
  3. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/configuration.py +1 -1
  4. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/create_finetuning_job.py +1 -1
  5. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/finetuning/manager.py +8 -22
  6. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/runner/model_adapter.py +7 -2
  7. {llmcomp-1.2.3 → llmcomp-1.2.4}/pyproject.toml +1 -1
  8. {llmcomp-1.2.3 → llmcomp-1.2.4}/.gitignore +0 -0
  9. {llmcomp-1.2.3 → llmcomp-1.2.4}/LICENSE +0 -0
  10. {llmcomp-1.2.3 → llmcomp-1.2.4}/docs/api.md +0 -0
  11. {llmcomp-1.2.3 → llmcomp-1.2.4}/docs/finetuning.md +0 -0
  12. {llmcomp-1.2.3 → llmcomp-1.2.4}/docs/generate_api_docs.py +0 -0
  13. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/free_form_question.py +0 -0
  14. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/ft_old_audubon_birds.jsonl +0 -0
  15. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/judges.py +0 -0
  16. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/model_adapter.py +0 -0
  17. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/next_token_question.py +0 -0
  18. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/openrouter.py +0 -0
  19. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/questions.yaml +0 -0
  20. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/questions_in_yaml.py +0 -0
  21. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/rating_question.py +0 -0
  22. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/runner.py +0 -0
  23. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/tinker.py +0 -0
  24. {llmcomp-1.2.3 → llmcomp-1.2.4}/examples/x_mod_57.py +0 -0
  25. {llmcomp-1.2.3 → llmcomp-1.2.4}/lint.sh +0 -0
  26. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/__init__.py +0 -0
  27. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/config.py +0 -0
  28. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/default_adapters.py +0 -0
  29. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/finetuning/__init__.py +0 -0
  30. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/finetuning/update_jobs.py +0 -0
  31. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/question/judge.py +0 -0
  32. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/question/plots.py +0 -0
  33. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/question/question.py +0 -0
  34. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/question/result.py +0 -0
  35. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/runner/chat_completion.py +0 -0
  36. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/runner/runner.py +0 -0
  37. {llmcomp-1.2.3 → llmcomp-1.2.4}/llmcomp/utils.py +0 -0
  38. {llmcomp-1.2.3 → llmcomp-1.2.4}/scripts/migrate_to_org_id.py +0 -0
  39. {llmcomp-1.2.3 → llmcomp-1.2.4}/tests/__init__.py +0 -0
  40. {llmcomp-1.2.3 → llmcomp-1.2.4}/tests/conftest.py +0 -0
  41. {llmcomp-1.2.3 → llmcomp-1.2.4}/tests/test_config.py +0 -0
  42. {llmcomp-1.2.3 → llmcomp-1.2.4}/tests/test_hash_and_cache.py +0 -0
  43. {llmcomp-1.2.3 → llmcomp-1.2.4}/tests/test_question.py +0 -0
  44. {llmcomp-1.2.3 → llmcomp-1.2.4}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llmcomp
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Summary: Research library for black-box experiments on language models.
5
5
  Project-URL: Homepage, https://github.com/johny-b/llmcomp
6
6
  Project-URL: Repository, https://github.com/johny-b/llmcomp
@@ -78,10 +78,11 @@ Examples 1-4 demonstrate all key functionalities of llmcomp.
78
78
  | 7 | [tinker.py](examples/tinker.py) | Using Tinker models via OpenAI-compatible API. |
79
79
  | 8 | [openrouter.py](examples/openrouter.py) | Using OpenRouter models via OpenAI-Compatible API. |
80
80
  | 9 | [model_adapter.py](examples/model_adapter.py) | Setting model-specific API parameters |
81
- | 10 | [x_mod_57.py](examples/x_mod_57.py) | Complete script I used for a short blogpost. |
82
81
  | 11 | [runner.py](examples/runner.py) | Direct Runner usage for low-level API interactions. |
83
82
  | 12 | [create_finetuning_job.py](examples/create_finetuning_job.py) | Create an OpenAI [finetuning](#finetuning) job & manage models. |
83
+ | 13 | [emergent misalignment replication](https://github.com/emergent-misalignment/emergent-misalignment/blob/main/evaluation/evaluate_openai.py) | Complete script replicating results from a paper |
84
84
  | 13 | [old bird names replication](https://github.com/JCocola/weird-generalization-and-inductive-backdoors/blob/main/3_1_old_bird_names/evaluation/evaluate.py) | Complete script replicating results from a paper |
85
+ | 14 | [x_mod_57.py](examples/x_mod_57.py) | Complete script I used for a short blogpost. |
85
86
 
86
87
  ## Model provider configuration
87
88
 
@@ -97,7 +98,7 @@ You can interfere with this process:
97
98
  ```
98
99
  from llmcomp import Config
99
100
 
100
- # See all pairs based on the env variables
101
+ # See all pairs read from the env variables
101
102
  print(Config.url_key_pairs)
102
103
 
103
104
  # Get the OpenAI client instance for a given model.
@@ -106,10 +107,10 @@ print(client.base_url, client.api_key[:16] + "...")
106
107
 
107
108
  # Set the pairs to whatever you want.
108
109
  # You can add other OpenAI-compatible providers, or e.g. local inference.
109
- Config.url_key_pairs = [("http://localhost:8000/v1", "fake-key")]
110
+ Config.url_key_pairs = [("http://localhost:8000/v1", "fake-key", "FAKE_API_KEY")]
110
111
  ```
111
112
 
112
- This has an unintended consequence: llmcomp sends some nonsensical requests. E.g. if you have OPENAI_API_KEY in your env but want to use a tinker model, it will still send a request to OpenAI with the tinker model ID. This is easy to improve, but also doesn't seem important.
113
+ This provider discovery process has an unintended consequence: llmcomp sends some nonsensical requests. E.g. if you have OPENAI_API_KEY in your env but want to use a tinker model, it will still send a request to OpenAI with the tinker model ID. This is easy to improve, but also doesn't seem important.
113
114
 
114
115
  ## API reference
115
116
 
@@ -58,10 +58,11 @@ Examples 1-4 demonstrate all key functionalities of llmcomp.
58
58
  | 7 | [tinker.py](examples/tinker.py) | Using Tinker models via OpenAI-compatible API. |
59
59
  | 8 | [openrouter.py](examples/openrouter.py) | Using OpenRouter models via OpenAI-Compatible API. |
60
60
  | 9 | [model_adapter.py](examples/model_adapter.py) | Setting model-specific API parameters |
61
- | 10 | [x_mod_57.py](examples/x_mod_57.py) | Complete script I used for a short blogpost. |
62
61
  | 11 | [runner.py](examples/runner.py) | Direct Runner usage for low-level API interactions. |
63
62
  | 12 | [create_finetuning_job.py](examples/create_finetuning_job.py) | Create an OpenAI [finetuning](#finetuning) job & manage models. |
63
+ | 13 | [emergent misalignment replication](https://github.com/emergent-misalignment/emergent-misalignment/blob/main/evaluation/evaluate_openai.py) | Complete script replicating results from a paper |
64
64
  | 13 | [old bird names replication](https://github.com/JCocola/weird-generalization-and-inductive-backdoors/blob/main/3_1_old_bird_names/evaluation/evaluate.py) | Complete script replicating results from a paper |
65
+ | 14 | [x_mod_57.py](examples/x_mod_57.py) | Complete script I used for a short blogpost. |
65
66
 
66
67
  ## Model provider configuration
67
68
 
@@ -77,7 +78,7 @@ You can interfere with this process:
77
78
  ```
78
79
  from llmcomp import Config
79
80
 
80
- # See all pairs based on the env variables
81
+ # See all pairs read from the env variables
81
82
  print(Config.url_key_pairs)
82
83
 
83
84
  # Get the OpenAI client instance for a given model.
@@ -86,10 +87,10 @@ print(client.base_url, client.api_key[:16] + "...")
86
87
 
87
88
  # Set the pairs to whatever you want.
88
89
  # You can add other OpenAI-compatible providers, or e.g. local inference.
89
- Config.url_key_pairs = [("http://localhost:8000/v1", "fake-key")]
90
+ Config.url_key_pairs = [("http://localhost:8000/v1", "fake-key", "FAKE_API_KEY")]
90
91
  ```
91
92
 
92
- This has an unintended consequence: llmcomp sends some nonsensical requests. E.g. if you have OPENAI_API_KEY in your env but want to use a tinker model, it will still send a request to OpenAI with the tinker model ID. This is easy to improve, but also doesn't seem important.
93
+ This provider discovery process has an unintended consequence: llmcomp sends some nonsensical requests. E.g. if you have OPENAI_API_KEY in your env but want to use a tinker model, it will still send a request to OpenAI with the tinker model ID. This is easy to improve, but also doesn't seem important.
93
94
 
94
95
  ## API reference
95
96
 
@@ -69,7 +69,7 @@ Config.url_key_pairs.append(("https://my-custom-endpoint.com/v1", "sk-my-custom-
69
69
  # Config.url_key_pairs = [p for p in Config.url_key_pairs if "openrouter" not in p[0]]
70
70
 
71
71
  # Or replace entirely:
72
- # Config.url_key_pairs = [("https://api.openai.com/v1", "sk-...")]
72
+ # Config.url_key_pairs = [("https://api.openai.com/v1", "sk-...", "SOME_API_KEY")]
73
73
 
74
74
  # Set to None to re-discover from environment on next access:
75
75
  Config.url_key_pairs = None
@@ -49,7 +49,7 @@ SEED = None
49
49
  SUFFIX = DATASET.replace("_", "-")
50
50
  if LR_MULTIPLIER != "auto":
51
51
  SUFFIX += f"-lr{LR_MULTIPLIER}"
52
- SUFFIX.replace(".", "-") # OpenAI does that either way
52
+ SUFFIX = SUFFIX.replace(".", "-") # OpenAI does that either way
53
53
 
54
54
  # %%
55
55
  manager = FinetuningManager()
@@ -431,28 +431,14 @@ class FinetuningManager:
431
431
  return cls._org_cache[api_key]
432
432
 
433
433
  client = openai.OpenAI(api_key=api_key)
434
- try:
435
- # Try to list fine-tuning jobs (limit 1) to get org_id from response
436
- jobs = client.fine_tuning.jobs.list(limit=1)
437
- if jobs.data:
438
- org_id = jobs.data[0].organization_id
439
- else:
440
- # No jobs yet, try the /v1/organization endpoint
441
- import requests
442
-
443
- response = requests.get(
444
- "https://api.openai.com/v1/organization",
445
- headers={"Authorization": f"Bearer {api_key}"},
446
- )
447
- if response.status_code == 200:
448
- org_id = response.json().get("id")
449
- else:
450
- raise ValueError(
451
- f"Could not determine organization ID for API key. "
452
- f"API returned status {response.status_code}"
453
- )
454
- except Exception as e:
455
- raise ValueError(f"Could not determine organization ID: {e}")
434
+
435
+ # Try to list fine-tuning jobs (limit 1) to get org_id from response
436
+ jobs = client.fine_tuning.jobs.list(limit=1)
437
+ if jobs.data:
438
+ org_id = jobs.data[0].organization_id
439
+ else:
440
+ # There's no way to get the organization ID from the API key alone.
441
+ raise ValueError("First finetuning job in a new project must be created manually. See https://github.com/johny-b/llmcomp/issues/42.")
456
442
 
457
443
  cls._org_cache[api_key] = org_id
458
444
  return org_id
@@ -79,8 +79,13 @@ class ModelAdapter:
79
79
 
80
80
  if cls._is_reasoning_model(model):
81
81
  # Reasoning models need max_completion_tokens and reasoning_effort
82
- params["max_completion_tokens"] = 16
83
- params["reasoning_effort"] = "none"
82
+ params["max_completion_tokens"] = 32
83
+ if model.startswith("o"):
84
+ reasoning_effort = "low"
85
+ else:
86
+ reasoning_effort = "none"
87
+
88
+ params["reasoning_effort"] = reasoning_effort
84
89
  else:
85
90
  params["max_tokens"] = 1
86
91
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "llmcomp"
7
- version = "1.2.3"
7
+ version = "1.2.4"
8
8
  description = "Research library for black-box experiments on language models."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes