## 1. Initialize Cache (Preprocessing Phase)
```python
builder = LVISLocalCacheBuilder(
    annotation_path="lvis_v1_val.json",
    coco_image_root="/path/to/coco/images",
    cache_size=100,
    clip_threshold=0.7,
    momentum=0.8
)
builder.build_initial_cache(save_path="lvis_cache_init.pth")
```
## 2. Dynamic Update During Training
```python
# Load initial cache
checkpoint = torch.load("lvis_cache_init.pth")
builder.load_cache_state(checkpoint)

# Simulate training loop
for epoch in range(epochs):
    for batch in train_loader:
        # Assume batch contains new images and annotations
        images, bboxes = batch
        
        # Generate new features
        new_text_embeds, new_visual_embeds = [], []
        for img, bbox in zip(images, bboxes):
            # Generate descriptions and filter with CLIP (adjust interface as needed)
            descs = builder.generate_descriptions(img, bbox)
            text_embeds, visual_embeds = builder.filter_with_clip(descs, img, bbox)
            new_text_embeds.append(text_embeds)
            new_visual_embeds.append(visual_embeds)
        
        # Concatenate features
        new_text_embeds = torch.cat(new_text_embeds)
        new_visual_embeds = torch.cat(new_visual_embeds)
        
        # Momentum update for the cache
        builder.update_cache(new_text_embeds, new_visual_embeds)
        
        # Train the model...
        
    # Save checkpoint for each epoch
    torch.save(builder.get_cache_state(), f"lvis_cache_epoch{epoch}.pth")
