> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wearer.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Advanced Configuration

> Configure Transfer Learning for your specific needs

# Advanced Configuration

Transfer Learning provides extensive configuration options to customize its behavior for your specific needs. This guide covers all available configuration options and how to use them.

## Configuration Methods

There are several ways to configure Transfer Learning:

<CardGroup cols={2}>
  <Card title="Environment Variables" icon="gear" color="#4f46e5">
    Set environment variables directly in your shell or in a `.env` file
  </Card>

  <Card title="CLI Options" icon="terminal" color="#0ea5e9">
    Pass options directly to CLI commands
  </Card>

  <Card title="Config Command" icon="sliders" color="#10b981">
    Use the `config` command to view and modify settings
  </Card>

  <Card title="Configuration Files" icon="file" color="#f59e0b">
    Create custom configuration files for different projects
  </Card>
</CardGroup>

## Environment Variables

The most common way to configure Transfer Learning is through environment variables. These can be set in your shell or in a `.env` file in the project root directory.

### Core Settings

<ResponseField name="OPENAI_API_KEY" type="string" required>
  Your OpenAI API key for accessing GPT-4 Vision models.
</ResponseField>

<ResponseField name="ANTHROPIC_API_KEY" type="string" optional>
  Your Anthropic API key for Claude models (optional).
</ResponseField>

<ResponseField name="HUGGINGFACE_API_KEY" type="string" optional>
  Your Hugging Face API key for accessing models (optional).
</ResponseField>

### Processing Settings

<ResponseField name="FRAME_EXTRACTION_INTERVAL" type="integer" default="30">
  Interval between frame extractions (in frames).
</ResponseField>

<ResponseField name="MAX_FRAMES_PER_VIDEO" type="integer" default="100">
  Maximum number of frames to extract per video.
</ResponseField>

<ResponseField name="BATCH_SIZE" type="integer" default="30">
  Number of frames to process in each batch.
</ResponseField>

<ResponseField name="MAX_CONCURRENT_BATCHES" type="integer" default="100">
  Maximum number of concurrent batches to process.
</ResponseField>

<ResponseField name="SUPPORTED_VIDEO_FORMATS" type="string" default=".mp4,.avi,.mov,.mkv">
  Comma-separated list of supported video formats.
</ResponseField>

<ResponseField name="MAX_VIDEO_SIZE_MB" type="integer" default="500">
  Maximum video size in megabytes.
</ResponseField>

### Model Settings

<ResponseField name="OPENAI_MODEL" type="string" default="gpt-4o-mini">
  OpenAI model to use for guide generation.
</ResponseField>

<ResponseField name="VISION_MODEL" type="string" default="o3-mini">
  Vision model to use for image analysis.
</ResponseField>

<ResponseField name="FAST_MODEL" type="string" default="gpt-4o-mini">
  Faster model to use for simpler tasks.
</ResponseField>

<ResponseField name="WHISPER_MODEL" type="string" default="base">
  Whisper model to use for transcription (tiny, base, small, medium, large).
</ResponseField>

<ResponseField name="WHISPER_DEVICE" type="string" default="cpu">
  Device to use for Whisper transcription (cpu, cuda).
</ResponseField>

<ResponseField name="WHISPER_COMPUTE_TYPE" type="string" default="int8">
  Compute type for Whisper models (float16, int8).
</ResponseField>

### Cache Settings

<ResponseField name="ENABLE_CACHE" type="boolean" default="true">
  Enable or disable caching.
</ResponseField>

<ResponseField name="CACHE_TTL_HOURS" type="integer" default="24">
  Time-to-live for cache entries in hours.
</ResponseField>

### Monitoring Settings

<ResponseField name="ENABLE_MONITORING" type="boolean" default="true">
  Enable or disable monitoring and metrics collection.
</ResponseField>

<ResponseField name="LOG_LEVEL" type="string" default="INFO">
  Logging level (DEBUG, INFO, WARNING, ERROR).
</ResponseField>

<ResponseField name="METRICS_ENABLED" type="boolean" default="true">
  Enable or disable metrics collection.
</ResponseField>

## Using the Config Command

The `config` command allows you to view and modify configuration settings:

```bash theme={null}
# Show current configuration
transfer-learning config --show

# Reset configuration to defaults
transfer-learning config --reset
```

## Creating a Custom Configuration File

You can create a custom `.env` file for different projects:

```bash theme={null}
# Create a custom configuration file
cat > my-project.env << EOF
OPENAI_API_KEY=your-api-key-here
FRAME_EXTRACTION_INTERVAL=60
MAX_FRAMES_PER_VIDEO=50
BATCH_SIZE=20
WHISPER_MODEL=small
EOF

# Use the custom configuration file
export DOTENV_PATH=my-project.env
transfer-learning process-video path/to/video.mp4
```

## Directory Configuration

Transfer Learning uses several directories for storing data, logs, and metrics. You can customize these directories:

<ResponseField name="DATA_DIR" type="string" default="./data">
  Base directory for all data storage.
</ResponseField>

<ResponseField name="CACHE_DIR" type="string" default="./.cache">
  Directory for cache storage.
</ResponseField>

<ResponseField name="LOGS_DIR" type="string" default="./logs">
  Directory for log files.
</ResponseField>

<ResponseField name="VIDEOS_DIR" type="string" default="./data/videos">
  Directory for downloaded videos.
</ResponseField>

<ResponseField name="FRAMES_DIR" type="string" default="./data/frames">
  Directory for extracted frames.
</ResponseField>

<ResponseField name="TRANSCRIPTS_DIR" type="string" default="./data/transcripts">
  Directory for transcripts.
</ResponseField>

<ResponseField name="GUIDES_DIR" type="string" default="./data/guides">
  Directory for generated guides.
</ResponseField>

<ResponseField name="ANALYSIS_DIR" type="string" default="./data/analysis">
  Directory for analysis results.
</ResponseField>

<ResponseField name="TEMP_DIR" type="string" default="./data/temp">
  Directory for temporary files.
</ResponseField>

## Configuration Examples

<AccordionGroup>
  <Accordion title="High-Quality Processing">
    For high-quality processing with detailed guides:

    ```bash theme={null}
    # .env file
    OPENAI_API_KEY=your-api-key-here
    OPENAI_MODEL=gpt-4o
    VISION_MODEL=gpt-4-vision-preview
    FRAME_EXTRACTION_INTERVAL=15
    MAX_FRAMES_PER_VIDEO=200
    WHISPER_MODEL=medium
    ```
  </Accordion>

  <Accordion title="Fast Processing">
    For faster processing with lower resource usage:

    ```bash theme={null}
    # .env file
    OPENAI_API_KEY=your-api-key-here
    OPENAI_MODEL=gpt-4o-mini
    VISION_MODEL=o3-mini
    FRAME_EXTRACTION_INTERVAL=60
    MAX_FRAMES_PER_VIDEO=50
    BATCH_SIZE=10
    MAX_CONCURRENT_BATCHES=5
    WHISPER_MODEL=tiny
    ```
  </Accordion>

  <Accordion title="GPU Acceleration">
    For GPU-accelerated processing:

    ```bash theme={null}
    # .env file
    OPENAI_API_KEY=your-api-key-here
    WHISPER_MODEL=medium
    WHISPER_DEVICE=cuda
    WHISPER_COMPUTE_TYPE=float16
    ```
  </Accordion>

  <Accordion title="Detailed Logging">
    For detailed logging and debugging:

    ```bash theme={null}
    # .env file
    LOG_LEVEL=DEBUG
    ENABLE_MONITORING=true
    METRICS_ENABLED=true
    ```
  </Accordion>
</AccordionGroup>

## Command-Line Options

Most configuration options can also be passed directly to CLI commands:

```bash theme={null}
# Override batch size and model for a specific command
transfer-learning process-video path/to/video.mp4 --batch-size 15 --max-concurrent 10

# Use a specific model for guide generation
transfer-learning generate-guide data/videos/video_name --model gpt-4o --temperature 0.3
```

## Configuration Precedence

Configuration options are applied in the following order of precedence (highest to lowest):

1. Command-line options
2. Environment variables
3. `.env` file
4. Default values

This means that command-line options will override environment variables, which will override values in the `.env` file, which will override default values.

## Validating Configuration

You can validate your configuration using the `config` command:

```bash theme={null}
transfer-learning config --validate
```

This will check that all required configuration options are set and that values are within acceptable ranges.

## Troubleshooting

<Accordion title="Missing API Key">
  If you encounter errors about a missing API key:

  1. Check that your API key is correctly set in the `.env` file
  2. Verify that the `.env` file is in the correct location
  3. Try setting the API key as an environment variable:

  ```bash theme={null}
  export OPENAI_API_KEY=your-api-key-here
  ```
</Accordion>

<Accordion title="Directory Permissions">
  If you encounter errors about directory permissions:

  1. Check that the user running Transfer Learning has write permissions to the data directories
  2. Try setting custom directory paths in locations where you have write permissions:

  ```bash theme={null}
  export DATA_DIR=/path/with/write/permissions
  ```
</Accordion>

<Accordion title="Memory Issues">
  If you encounter memory issues during processing:

  1. Reduce the batch size with `--batch-size`
  2. Reduce the maximum concurrent batches with `--max-concurrent`
  3. Increase the frame extraction interval to process fewer frames

  ```bash theme={null}
  export FRAME_EXTRACTION_INTERVAL=60
  export BATCH_SIZE=10
  export MAX_CONCURRENT_BATCHES=5
  ```
</Accordion>
