Skip to content

Commit

Permalink
Lower Gemini safety settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyFaiz committed Jun 19, 2024
1 parent 58b8099 commit c9d32a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rl/llm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LLMConfig:
context_window_tokens: int = 0
max_new_tokens: int = 2048
temperature: float = 0.0
frequency_penalty: float = 0.05 # Experiment with this
frequency_penalty: float = 0.2 # Experiment with this
num_gpus: int | None = None
visible_devices: str | None = None

Expand Down
8 changes: 8 additions & 0 deletions rl/llm/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import torch
import tqdm.asyncio
from anthropic import Anthropic
from google.generativeai.types import HarmBlockThreshold, HarmCategory
from openai import OpenAI
from openai.types.chat import ChatCompletionMessageParam
from transformers import AutoTokenizer, PreTrainedTokenizer
Expand Down Expand Up @@ -271,6 +272,12 @@ def generate(self, prompt: ChatInput) -> InferenceOutput:
"response_mime_type": "text/plain",
},
system_instruction=system_message,
safety_settings={
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
},
)
chat_session = model.start_chat(history=prev_messages)
# Can't include the last message in the history, because
Expand Down Expand Up @@ -545,6 +552,7 @@ def _get_vllm_kwargs(llm_config):
"disable_log_stats": True,
"dtype": "auto",
"gpu_memory_utilization": 0.9,
"enable_prefix_caching": True,
"enable_lora": llm_config.lora_name_or_path is not None,
"max_lora_rank": 32,
}
Expand Down

0 comments on commit c9d32a4

Please sign in to comment.